2018-12-17 OC和C++混编需要注意的问题

方案一

1. .c文件的identify and type右边栏修改为Objective-C source

2. Built setting -> Apple Clang Language -> Compile Source AS设置为According to File type,即根据文件源类型来编译

方案二

1. 项目中使用到C或者C++的代码部分的.m文件,改为.mm

2.Built setting -> Apple Clang Language -> Compile Source AS设置为Objective-C++,即指定为C++的编译机制

注意

如果项目中有些头文件导入方式是用modules的@import xxxx 类似的, 那么就不能用第二种方案,因为.mm和这个会冲突,导致整个项目编译不过, 一般报错像这样 "Use of '@import' when C++ modules are disabled, consider using -fmodules and -fcxx-modules"

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容