views:

493

answers:

1

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?

+1  A: 

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
Dave Rigby