开发者

Objective C syntax inside .cpp file?

I'm t开发者_Python百科rying to copy over some example code into my own project. The example project is iPhoneExtAudioFileConvertTest from the sdk. The example project contains a file called ExtAudioFileConvert.cpp. This file contains what looks like Objective-C code:

assert([NSThread isMainThread]);

The example project runs fine, but the compiler complains about the code above when I build my own project: error: expected primary-expression before '[' token

What's going on here? Obviously there's some way to use objective c bracket syntax in a .cpp file. What do I need to do to make it work?


Change the file extension to .mm for Objective-C++ instead of just .cpp for C++.


The default build settings of iPhoneExtAudioFileConvertTest is Objective-C++.
If you change the settings to According to File Type, you will get the same error message.

So, change the file extension to .mm or change the build settings of your project.

Objective C syntax inside .cpp file?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜