• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Why is typedef needed with struct and enum?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is typedef needed with struct and enum?


  • Subject: Re: Why is typedef needed with struct and enum?
  • From: "Justin C. Walker" <email@hidden>
  • Date: Fri, 8 Jul 2005 19:43:19 -0700


On Jul 8, 2005, at 19:24 , Jerry Krinock wrote:

In CodeWarrior, I've always done the following, which according to my C/C++
textbook is perfectly good syntax:


struct MyStruct
{
    int n1 ;
    int n2 ;
}  ;

enum NodeType
{
    kRoot = 1,
    kFolder = 2
} ;

But after porting my code to Xcode, getting errors and then looking at
others' Xcode code, I learned that I now have to do this:

typedef struct MyStruct_type
{
    int n1 ;
    int n2 ;
} MyStruct ;

typedef enum
{
    kRoot = 1,
    kFolder = 2
} NodeType ;

Which is OK, according to my book, but why does Xcode make me do all this
extra typing? I'm afraid that I'm missing an important point.

A minor bit of terminology: Xcode is an IDE; it isn't making you do any of this. If you are getting complaints during compilation, they are coming from gcc/g++, the compilers normally used for Mac OS X.


One thing to be aware of is that succeeding versions of gcc/g++ are more, um, pedantic about the language they accept (and, at least for C ++, the language is a sort of moving target as well). There are a wealth of flags that you can set for your projects and targets that will affect exactly what the compiler accepts as "legal".

Without seeing more code and errors, it's hard to say what is happening.

Regards,

Justin

--
Justin C. Walker, Curmudgeon-At-Large
Institute for General Semantics
--------
Men are from Earth.
Women are from Earth.
   Deal with it.
--------


_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Why is typedef needed with struct and enum? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Why is typedef needed with struct and enum?
  • Next by Date: Re: Why is typedef needed with struct and enum?
  • Previous by thread: Why is typedef needed with struct and enum?
  • Next by thread: Re: Why is typedef needed with struct and enum?
  • Index(es):
    • Date
    • Thread