2018-12-17 OC和C++混编需要注意的问题
2018-12-17 本文已影响12人
BoooBooo冰Booo
方案一
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"