Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What Are Some Quirks/Surprises with Using .mm Files in Objective-C?

I want to use some C++ STL collections in my Objective-C iPhone app. Apparently this is possible by giving files the extension ".mm" . What are some of the quirks/surprises associated with this?

I want to use the basic containers that I'm familiar with (vector, queue, set, ...)

Cheers!

like image 704
MrDatabase Avatar asked May 05 '09 04:05

MrDatabase


Video Answer


2 Answers

See Using C++ With Objective-C for a detailed list of what you can and can't do. You can do most things that you would expect. You just can't do things like have a C++ class inherit from an Objective-C class or vice-versa, you can't mix C++ exceptions with Objective-C exceptions, and C++ introduces several new keywords not present in Objective-C.

like image 62
Adam Rosenfield Avatar answered Sep 27 '22 20:09

Adam Rosenfield


The major quirk of Objective-C++ is that if you don't pass -fobjc-call-cxx-cdtors to g++, it won't call the constructor and destructor of C++ instance variables in of ObjC objects. So remember to turn that option on and you should be good.

like image 25
the fridge owl Avatar answered Sep 27 '22 20:09

the fridge owl