• 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: C++ in precompile
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C++ in precompile


  • Subject: Re: C++ in precompile
  • From: Eric Albert <email@hidden>
  • Date: Tue, 6 Dec 2005 09:48:12 -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.

You can certainly have C++ code in precompiled headers. The thing you're hitting is that Xcode builds a precompiled header for every language in your project, so if you have C code Xcode will build a C version of the precompiled header in addition to the C++ version.


The fix is to use #ifdef __cplusplus, like this:

#include <Carbon/Carbon.h>

#ifdef __cplusplus
class myClass;
#endif

If you want to have Objective-C code in your precompiled header, you can do the same with #ifdef __OBJC__.

Hope this helps,
Eric

_______________________________________________
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: 
 >C++ in precompile (From: Rob Crawford <email@hidden>)

  • Prev by Date: Re: Perforce with multiple depots
  • Next by Date: Re: C++ in precompile
  • Previous by thread: C++ in precompile
  • Next by thread: Re: C++ in precompile
  • Index(es):
    • Date
    • Thread