Is there any way to call c++ functions from objective-c code without .mm extension?
For example maybe it is possible to create a C wrapper or anything else that can help in this situation?
I know that it is possible assign type “objective-c++ source” for .m files but it is not what I want.
Is there any way to call c++ functions from objective-c code without .mm extension?
Share
Yes, I do this often. You will need a small amount of
.mmglue code, but your intuition of using wrappers is correct. You may be interested in Wrapping C++ – Take 2.There are good reasons to avoid excessive use of .mm files. They compile slower, run slower (particularly under ARC where they incur significant overhead), confuse gdb in my experience, and the mixing of ObjC and C++ classes is quite confusing and error-prone. Segmenting your ObjC and C++ with a thin layer between them is a good approach.