#include没有这样的文件或目录。

时间:2021-05-21 02:04:55

So I need to use vectors in my project. I have changed the .m file to .mm to make it Objective-C++. But, when I try saying:

所以我需要在项目中使用向量。我已经将.m文件更改为.mm以使其成为objective - c++。但是,当我试着说:

#include <vector>

In my .h it says the file or directory can not be found. If I put that line of code though in my .mm file though the error doesn't appear, but since I need a vector in the @interface (which is in my .h) what should I do to make the .h file find the vector file?

在my .h中,它表示无法找到文件或目录。如果我把这行代码放到。mm文件中,虽然错误不会出现,但是因为我需要一个@interface中的向量(在我的。h中)我应该怎么做才能使.h文件找到向量文件?

Also, I have tried changing it to compiling everything as Objective-C++, but that doesn't work because I get some errors in the Cocos2d library I am using...

另外,我试着将它转换为objective - c++,但这不起作用,因为我在Cocos2d库中有一些错误。

2 个解决方案

#1


27  

Is your .h file being included in any OTHER .h or .m files?

您的.h文件是否包含在其他的.h或.m文件中?

If so, you'll have to make those (or files including them, etc) into .mm as well.

如果是这样的话,你就得把那些(或文件包括它们等)变成。mm。

#2


6  

Without changing any .m to .mm or anything like that, if you click your project, click tagets->build settings go all the way down to "LLVM GCC 4.2 - Languages" you will see Compile Sources As change that value to Objective-C++;

如果你点击你的项目,点击tagets->构建设置一直到“LLVM GCC 4.2 -语言”,你将会看到编译源会把这个值变成Objective-C++;

#1


27  

Is your .h file being included in any OTHER .h or .m files?

您的.h文件是否包含在其他的.h或.m文件中?

If so, you'll have to make those (or files including them, etc) into .mm as well.

如果是这样的话,你就得把那些(或文件包括它们等)变成。mm。

#2


6  

Without changing any .m to .mm or anything like that, if you click your project, click tagets->build settings go all the way down to "LLVM GCC 4.2 - Languages" you will see Compile Sources As change that value to Objective-C++;

如果你点击你的项目,点击tagets->构建设置一直到“LLVM GCC 4.2 -语言”,你将会看到编译源会把这个值变成Objective-C++;