2

尝试将 .mm 文件导入另一个文件时出现错误。它的构建是这样的:

第一类FailedMenuLayer是 .mm 并且在它的 .h 中有:

#import "gameScene.h"

第二类 gameScene是 .mm,在它的 .h 中有:

#import "FailedMenuLayer.h"
   FailedMenuLayer *menuGO; //here i get the error: unknown type FailedMenuLayer .

这是为什么 ?

4

2 回答 2

2

It looks like an import cycle.

One way to fix it is to move the "gameScene.h" import to the .mm file. It's actually a good practice to keep the imports in the .h file limited only to what you actually need in the header and keep everything else in the .mm file.

If you need the import in the header try using @class instead of #import;

@class gameScene;

Don't forget to import gameScene.h in the .mm file also.

于 2013-06-18T11:09:43.370 回答
0

您不是在导入“.mm”文件,而是在导入它的标题。

检查您的构建阶段> 为要在此处列出的 .mm 文件编译源代码。那可能是你的问题

于 2013-06-18T09:25:39.667 回答