Reputation: 25011
I'm compiling a .mm file (Objective-C++) for an iPhone application, and the precompiled header fails to include the base classes.
I tracked it down to the following:
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif
Turns out, __OBJC__
is undefined for mm files, whereas it is defined for standard m files.
Is there any other flag I can use instead?
Upvotes: 2
Views: 1415
Reputation: 9640
If you invoke gcc with -dM -E
it will stop after preprocessing, and list all #defines
. This normally how I check what built-in defines are set; however I just tried this with a test .mm
file and __OBJC__
is defined for me, so I'm not sure why it isn't defined for you.
$ echo "int foo() {};" > tmp.mm
$ gcc -dM -E tmp.mm|grep OBJ
#define __OBJC__ 1
#define OBJC_NEW_PROPERTIES 1
Upvotes: 2