Objective-C & C++
Is it possible to mix C++ source code with Objective-C source code (useful for porting a PC game to Cocoa). Any problems/fyi's to know about, if it is possible?
Thanks,
Mark
Thanks,
Mark
Yes, name files with the .mm extension. Compiling will be very slow though.
So could an ordinary ObjC (no C++ code used) be .mm as well (for simplistic sake...). Also, is it just compile times, or are run times slow as well? Thanks for your prompt reply.
Mark
Mark
Run time is fine. It's just a hit at compile time.
Personally, when I need to do stuff like this, I just make a wrapper C++ class with a pure C++ header file. Then C++ code can call the wrapper without needing to be Objective-C++.
For example, just a few days ago I wrote a complete C++ binding to NSUserDefaults and NSDictionary, using stl::map and the like as my C++ datatype. very clean, very easy to call from pure C++ code.
Personally, when I need to do stuff like this, I just make a wrapper C++ class with a pure C++ header file. Then C++ code can call the wrapper without needing to be Objective-C++.
For example, just a few days ago I wrote a complete C++ binding to NSUserDefaults and NSDictionary, using stl::map and the like as my C++ datatype. very clean, very easy to call from pure C++ code.
I recently described how I keep my own C++ and ObjC++ code segregated in this thread: http://www.idevgames.com/forum/showthread.php?t=8221
Measure twice, cut once, curse three or four times.