Search code examples
c++objective-cxcode4compilation

compiling C++ and ObjC files in same Project


I don't know if this is some silly mistake from my end, or Xcode 4.2.1 is doing something, but I'm unable to compile even a simple project that has both C++ and ObjC files. I've done this in past, but somehow the compiler is treating the C++ header files as ObjC header and throwing silly errors like

Test.h

I'm able to compile if I force to compile all files as ObjectiveC++ from "Project Settings > Apple LLVM compiler 3.0 - Language > Compile Sources As". But, that is just a workaround and I don't want to fight any thing silly when the code has grown.


Solution

  • I just did this with a project I am working on. I believe @pmjordan is right, you need to rename any files referencing the C++ code to .mm files, rather than .m.