Re: typedef problem in Xcode 2.2
Re: typedef problem in Xcode 2.2
- Subject: Re: typedef problem in Xcode 2.2
- From: "Clark Cox" <email@hidden>
- Date: Tue, 21 Mar 2006 13:30:00 -0500
On 3/21/06, Ando Sonenblick <email@hidden> wrote:
>
>
>
> Gang,
>
>
>
> I'm porting old code from Codewarrior to Xcode 2.2 (not using the project
> importer, just building a new xcode project from scratch) and I have a
> problem with typedefs. This is all C++ code and I have set Xcode to always
> use the C++ compiler.
>
>
>
> In a .h file I have a typedef:
>
>
>
> typedef unsigned char *PascalStringPtr;
>
>
>
> I have another .h file that includes the above .h file and then in a class
> declaration uses the new type PascalStringPtr:
>
>
>
> Class String
>
> {
>
> PascalStringPtr fString;
>
> …
>
> };
>
>
>
> Xcode complains that PascalStringPtr "does not name a type".
>
>
>
> After some futzing around I found out that:
>
>
>
> Xcode is indeed "reaching" the typedef: I put #error before and after the
> typedef and both errors are spit out by Xcode; however:
>
>
>
> Xcode isn't really "consuming" the typedef: I changed it to "typedef
> GregorianChant *PascalStringPtr;" and Xcode did not complain about that at
> all – and I feel confident there's no inherent C type of "GregorianChant"!!!
> J
>
>
>
>
>
> So what the heck is going on here?!?!?
>
>
>
> I did some searching and found a posting
> (http://gcc.gnu.org/ml/gcc-help/2005-06/msg00097.html)
> about someone who had a similar experience and the issue was related to an
> X.h file including a Y.h file which itself then included X.h, etc.
That would be my first guess at what is happening to you as well.
>
>
>
> I don't have my code at this computer so I can't test this out today. My .h
> files are ALL protected with :
>
>
>
> #ifndef __FOO__
>
> #define __FOO__
>
>
>
> …
>
>
>
> #endif
>
>
>
> …which should preclude a lot (but not necessarily all) of nested and
> incestuous .h file inclusion problems.
>
>
>
> Can anyone shed any light on this problem? Is it indeed .h files including
> other .h files that then include the original .h file?
>
>
>
> Is there any compiler setting I can play with to work around this? Do I
> have to re configure my #includes?
Well, if you do indeed have circular includes, then my only advice is:
"Don't do that!" :). Try moving any declarations that you need in both
headers into a third header that is then included by both.
--
Clark S. Cox III
email@hidden
My CV/Resume:
http://homepage.mac.com/clarkcox3/files/Resume.pdf
http://homepage.mac.com/clarkcox3/files/Resume.html
_______________________________________________
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