Re: C++ in precompile
Re: C++ in precompile
- Subject: Re: C++ in precompile
- From: Chris Espinosa <email@hidden>
- Date: Tue, 6 Dec 2005 09:48:41 -0800
On Dec 6, 2005, at 9:12 AM, Rob Crawford wrote: I have a precompile that has C++ in it (came over from CodeWarrior), a lot of forward declared class and such. In the beginning you could not have C++ in precompiles in ProjectBuilder, is this still the case XCode and if not, what do you need to do to tell the precompile to compile with C++?
precompile looks something like this....
#include <Carbon/Carbon.h>
class myClass;
I get errors on the "class myClass;" line.
If you have both C and C++ sources in your project, Xcode will automatically create both C and C++ precompiled headers from your prefix file. It's your responsibility to make sure the C side doesn't include C++ headers, or to force the C code to be compiled by the C++ compiler.
To do the former,bracket the #include lines for C++ headers with
#ifdef __cplusplus #include <string> #endif
If you don't want to do this (and there are many reasons not to), you can force .c files to be compiled as C++, which in general is what CodeWarrior does.
Do this either by finding all .c files, choosing Get Info, and changing their file types to 'sourcecode.cpp.cpp', or just going to your target settings and add '-x c++' to Other C Flags.
Chris |
_______________________________________________
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