views:

51

answers:

2

Consider the followng situation:

MacFont.h

struct MacFont : Font
{
  // ...

  NSFont* font;
};

MacFont will be implemented in MacFont.mm

FontEngine.cpp:

#if defined(OS_MAC)
#include "MacFont.h"
#elif
// ...
#endif

//...

In order to make it compiling, I should rename FontEngine.cpp to FontEngine.mm but I'm not allowed to.

So what now?

A: 

You can only compile ObjC things (e.g. NSFont) into a ObjC file (ir .m or .mm) so you can only do the rename.

You could create another C++ object inheriting from the C++ object in FontEngine.cpp and then that C++ object can have implementation including Obj C parts.

Mark
+3  A: 

If you cannot change the filename, don't fret. Consult your compiler manual for an option to force the filetype, and tell the compiler that this file, regardless of extension, is an Objective-C++ file.

jer
Hm, I did -x objective-c++ but I still get errors like stray @ in program ...
Schwitzgabel