从正在运行的iOS项目中导入.CPP文件,然后重命名为.mm问题 [英] Import .CPP files from a working iOS project and rename to .mm issue

查看:386
本文介绍了从正在运行的iOS项目中导入.CPP文件,然后重命名为.mm问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将一个.CPP及其.h文件从一个工作项目复制到一个新项目中.

I have copied a .CPP and its .h file from a working project to a new one.

我将.CPP的结尾重命名为.mm,但仍然给我错误.

I renamed the ending from .CPP to .mm but it still gives me errors.

在.h文件中,类定义附近 class MeterTable,表示希望;

In the .h file, near the class definition class MeterTable, it says it expect the ;

.mm文件中存在各种错误.

In the .mm file, there are all kinds of errors.

我认为,通过更改实现文件.mm的结尾,它将清除所有这些错误.是的,在旧项目下编译的原始.CPP文件.

I thought by changing the ending of the implementation file .mm it would clean all those errors. And yes, the original .CPP file compiled under the old project.

推荐答案

好像您将.h文件包含在其他.m文件中一样.您不能仅将C ++头文件包含在C或Objective-C源文件中.您需要确保您的C ++接口是C兼容的(没有类,只有自由函数而没有重载).或者,您必须将项目中的所有.m文件更改为.mm.

Looks like you're including that .h file into some other .m file. You cannot just include C++ header into a C or Objective-C source file. You need to make sure that your C++ interface is C compatible (no classes, only free functions without overloading). Or you would have to change all your .m files in the project into .mm.

这篇关于从正在运行的iOS项目中导入.CPP文件,然后重命名为.mm问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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