简体   繁体   English

C ++和Objc编译错误

[英]C++ and Objc Build Errors

I have been trying to add MobileSynth to my application for some time now and I am only running into errors. 我已经尝试将MobileSynth添加到我的应用程序一段时间了,但是我只是遇到错误。

I have followed the steps here which explain how to add a project into another one. 我已按照此处介绍了如何将项目添加到另一个项目中的步骤进行操作。

When I compile, both projects are compiled correctly without errors, but the moment I try import the code into my objective C source code I get a large number of errors. 编译时,两个项目都正确编译,没有错误,但是当我尝试将代码导入到目标C源代码中时,我遇到了大量错误。

This is a screenshot of the errors. 这是错误的屏幕截图。 在此处输入图片说明

在此处输入图片说明

Im sure there are more errors than these as there seems to be something wrong with the dependencies. 我肯定错误比这些错误更多,因为依赖项似乎有问题。

I also approved Xcodes recommendation to convert the project 2 (containing the objective C viewcontrollers with .mm extensions and the .cpp files) from an old 3.something version to the version 4 project type, and made the snapshot. 我还批准了Xcodes的建议,将项目2(包含带有.mm扩展名的目标C Viewcontroller和.cpp文件)从旧的3.something版本转换为版本4项目类型,并制作了快照。 Didnt seem to change anything. 似乎并没有改变任何东西。

I am not sure how to solve these issues. 我不确定如何解决这些问题。 I would really appreciate any help. 我真的很感谢您的帮助。

使用using namespace代替namespace

You're aware that files that use C++ need the .mm extension. 您知道使用C ++的文件需要.mm扩展名。 You also need to consider import dependencies. 您还需要考虑导入依赖性。 Since this header contains C++, any other file that imports it will also need to have the .mm extension. 由于此标头包含C ++,因此导入该标头的任何其他文件也都必须具有.mm扩展名。 I'm almost positive that's what's happening to you. 我几乎肯定这就是你正在发生的事情。

I generally try to keep C++ quarantined to the implementation files for this very reason. 出于这个原因,我通常尝试将C ++隔离到实现文件中。

Also, for clarification on previous advice: 另外,为澄清先前的建议:

// Correct
namespace synth { class something; }

// Incorrect
using namespace synth { class something; } 

// Optional
namespace synth { class something; }
using namespace synth;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM