OC和C++混编需要注意的问题

文章首发于github.io 2018-12-17 21:01:55

方案一

  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"

posted @ 2020-03-06 13:18  CoderWGB  阅读(629)  评论(0编辑  收藏  举报