Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pure ObjC (.m) vs ObjC & Cpp (.mm) mix

Are there any pitfalls, when mixing Objective C & C++ in a .mm file, should I prefer sticking to just pure ObjC when possible?

like image 473
fspirit Avatar asked Aug 12 '26 09:08

fspirit


1 Answers

Besides the caveats described in the Objective-C++ section of the Objective-C Programming Guide, there's nothing scary about Objective-C++. It takes a lot longer to compile than Objective-C, however and using C++ in a header infects any code that includes that header with the Objective-C++ requirement. So for your sanity, and the sanity of any clients of your code, use Objective-C when possible in "public" APIs and Objective-C++ when necessary.

like image 184
Barry Wark Avatar answered Aug 15 '26 00:08

Barry Wark