Mixing Objective-C and C++

后端 未结 5 1906
粉色の甜心
粉色の甜心 2020-11-29 01:54

I\'m trying to mix Objective-C with C++. When I compile the code, I get several errors.

A.h

#import 
#include \"B.h\"

@interfac         


        
5条回答
  •  -上瘾入骨i
    2020-11-29 02:23

    You need to name your .m files .mm. And you will be able to compile C++ code with Objective-C.

    So, following your example, your AView.m file should be named AView.mm. It's simple as that. It works very well. I use a lot of std containers (std::vector, std::queue, etc) and legacy C++ code in iPhone projects without any complications.

提交回复
热议问题