Objective C使用C ++ POSIX类的项目 [英] Objective C Project using C++ POSIX Classes

查看:159
本文介绍了Objective C使用C ++ POSIX类的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用一些C ++ POSIX类的代码创建一个iOS程序。
我已经阅读了Apple Developer Center的Using C ++ With Objective-C手册。
他们描述如何混合C ++&目标C代码在.mm文件中。



我的问题是,是否有可能在正常的Objective C的.h / .m文件中使用C ++类项目?



还是有必要用这个.mm文件格式编写整个项目,它有自己的main?

.c , .m code>, .cpp .mm ,并根据扩展名自动选择编译器。例如,您可以保留XCode模板附带的标准 main.m 文件,并添加新的 .h .mm 文件以使用Objective-C ++。



换句话说, > normal Objective-C 项目和一个 Objective-C ++ 项目。你只需要使用 .mm 扩展为需要Objective-C ++的特定文件。这可以在任何项目中使用。


I have to create a iOS Programm using Code of some C++ POSIX Classes. I already read the "Using C++ With Objective-C" manual of the Apple Developer Center. They describe how to mix C++ & Objective C code in a .mm file.

My question is, is there any possibility to use the C++ Classes in my .h/.m files of a normal Objective C Project?

Or is it necessary to write the whole Project in that .mm file style with its own main?

解决方案

You can combine in a project any types of files, say .c, .m, .cpp and .mm, and the compiler is chosen automatically depending on the extension. For example, you can keep the standard main.m file which comes with the XCode template, and add your new .h and .mm files to use Objective-C++.

In other words, there's no distinction between a normal Objective-C project and a Objective-C++ project. You just have to use .mm extension for the specific files which needs Objective-C++. This can be used in any project.

这篇关于Objective C使用C ++ POSIX类的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆