Openfeint 导致了这个:ISO C++禁止声明“myClass”没有类型
长话短说,我的项目(一个 iPhone 应用程序)一直运行良好,直到我开始使用 C++ sdk (openfeint)。一切都工作正常,包括 C++ Openfeint 的东西,直到我从设备上的测试切换到模拟器中的测试。
现在它无法编译任何东西,并且我收到了不到 200 个错误。这一切都失去了控制,并且无法在任何设备上编译。正如我所说,一切都很完美,我没有更改一行代码,我只是切换了 Active SDK。
所以我将从头开始。第一个错误是...
Error 1: ISO C++ forbids of declaration 'BrickControlLayer' with no type
单击此错误会将我带到另一个类的头文件...
// GameScene.h
#import <Foundation/Foundation.h>
#import "cocos2d.h"
#import "brickSprite.h"
#import "BrickControlLayer.h"
#import "GameState.h"
#import "ScoreController.h"
#import "FeedbackLayer.h"
#import "TimeBar.h"
@interface GameScene : Layer {
GameState *gameState;
ScoreController *scoreController;
CocosNode *spriteHolder;
brickSprite *targetBrick;
// Heres the line it takes me too <<<<<<<<<<<<<<<<<
BrickControlLayer *controls;
NSInteger difficulty;
NSMutableArray *pointsLookupArray;
BitmapFontAtlas *scoreLabel;
FeedbackLayer *feedback;
NSDate *startTime;
TimeBar *timeProgress;
int rowScanCount, foundRows;
}
// methods here....
@end
我对此很陌生,所以请耐心等待。我很困惑,因为我明确指出 *controls
的类型为“BrickControlLayer
”。所以我认为“BrickControlLayer”本身有问题。
这是标题......
// BrickControlLayer.h
#import <Foundation/Foundation.h>
#import "cocos2d.h"
#import "brickSprite.h"
#import "HighScores.h"
@interface BrickControlLayer : Layer{
CocosNode *spriteHolder;
CGPoint touchedStartPoint, moveFromPoint;
brickSprite *touchedBrick;
BOOL editorMode;
int movecount;
// Control buttons
AtlasSpriteManager *buttonManager;
AtlasSprite *rotLeft, *rotRight, *newBrick, *deleteBrick, *makeTarget, *save, *run;
BOOL tapToContinue;
}
@property (retain, readwrite) CocosNode *spriteHolder;
@property (retain, readwrite) brickSprite *touchedBrick;
-(void)showEditorControls;
-(void)selectBrickAtLocation:(CGPoint)location;
-(void)hideEditorControls;
-(void)deactivate;
@end
我已经一遍又一遍地阅读它。之前一切都很好,但我就是想不通。我一直在谷歌上搜索它,唯一出现的是术语“前向声明”,但这对我来说没有任何意义,而且我发现的所有信息都在谈论结构。
我怀疑这些错误更多地表明我做错了很多其他事情,而不是犯了简单的一行打字错误或其他错误。任何人都可以用外行人的话解释这里发生了什么吗?
To cut a long story short, my project (an iPhone app) was all working fine until I started using a C++ sdk (openfeint). Everything was working fine, including the C+++ Openfeint stuff, until I switched from tesitng on the device to testing in the simulator.
Now it won't compile for anything and I'm getting just under 200 errors. It's all just spiralled out of control and wont compile on any device. As I said, everything was working perfectly, I didn't change a single line of code, I simply switched Active SDK's.
So I'll start at the beginning. The first error is...
Error 1: ISO C++ forbids of declaration 'BrickControlLayer' with no type
Clicking on this error takes me to the header file for another class...
// GameScene.h
#import <Foundation/Foundation.h>
#import "cocos2d.h"
#import "brickSprite.h"
#import "BrickControlLayer.h"
#import "GameState.h"
#import "ScoreController.h"
#import "FeedbackLayer.h"
#import "TimeBar.h"
@interface GameScene : Layer {
GameState *gameState;
ScoreController *scoreController;
CocosNode *spriteHolder;
brickSprite *targetBrick;
// Heres the line it takes me too <<<<<<<<<<<<<<<<<
BrickControlLayer *controls;
NSInteger difficulty;
NSMutableArray *pointsLookupArray;
BitmapFontAtlas *scoreLabel;
FeedbackLayer *feedback;
NSDate *startTime;
TimeBar *timeProgress;
int rowScanCount, foundRows;
}
// methods here....
@end
I'm new to this, so bear with me. I was confused as I'm clearly stating that *controls
is of the type 'BrickControlLayer
'. So I'm thinking there's something wrong inside 'BrickControlLayer' itself.
Here's the header...
// BrickControlLayer.h
#import <Foundation/Foundation.h>
#import "cocos2d.h"
#import "brickSprite.h"
#import "HighScores.h"
@interface BrickControlLayer : Layer{
CocosNode *spriteHolder;
CGPoint touchedStartPoint, moveFromPoint;
brickSprite *touchedBrick;
BOOL editorMode;
int movecount;
// Control buttons
AtlasSpriteManager *buttonManager;
AtlasSprite *rotLeft, *rotRight, *newBrick, *deleteBrick, *makeTarget, *save, *run;
BOOL tapToContinue;
}
@property (retain, readwrite) CocosNode *spriteHolder;
@property (retain, readwrite) brickSprite *touchedBrick;
-(void)showEditorControls;
-(void)selectBrickAtLocation:(CGPoint)location;
-(void)hideEditorControls;
-(void)deactivate;
@end
I've been over it and over it. It was all working fine before and I simply can't figure it out. I've been googling it and the only thing that crops up is the term "Forward Declaration", but that doesn't mean anything to me and all the info I've found talks about structs.
I suspect the errors are more of an indication that I'm doing lot's of other things wrong, rather than committing a simple one line typo or something. Can anyone explain in laymans terms what's going on here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
来自 OpenFeint 的 Jason。如果您想将演示该问题的代码示例发送给 openfeint dot com 的开发支持,我们将为您查看。听起来您可能包含 .CPP 而不是 .MM 文件中的头文件。
如果您所做的只是更改 iPhone Target SDK,请仔细检查在设置编译器选项时是否对所有 SDK 和构建配置(发布、调试)进行了更改。
您收到的错误听起来像是编译器无法识别您处于 Objective-C 声明中,或者找不到 BrickControlLayer 的标头声明。可以是循环包含吗? (你使用 includeguards 或 #pragma 一次吗?)
希望有帮助,
- 贾森·西特伦
- 创始人&奥罗拉·假装首席执行官
Jason here from OpenFeint. If you'd like to send over a code sample to devsupport at openfeint dot com that demonstrates the problem we'll take a look at it for you. It sounds like you may be including the header file from a .CPP instead of a .MM file.
If all you did was change the iPhone Target SDK, double check that when you setup compiler options you did it for all SDKs and build configurations (release, debug).
The error you're getting sounds like the compiler doesn't recognize that you're in an Objective-C declaration OR it can't find the header declaration for BrickControlLayer. Could be a circular include? (do you use include guards or #pragma once?)
Hope that helps,
- Jason Citron
- Founder & CEO, Aurora Feint
您的错误是关于BrickController
而不是BrickControlLayer
,所以我认为您没有发布编译器实际上抱怨的行。话虽如此,我认为你的根本问题是你试图用一些东西来编译看起来像 Objective C 的文件,从它的错误消息来看,它认为它是一个 ISO C++ 编译器。
Your error is aboutBrickController
notBrickControlLayer
so I don't think that you've posted the line that the compiler is actually complaining about.Having said that, I think that your fundamental problem is that you are trying to compile files that look to be Objective C with something that, from it's error messages, thinks that it is an ISO C++ compiler.
您是否已按照集成 OpenFeint SDK 中列出的所有步骤进行操作 页面?
或者,您可以创建一个与 OpenFeint 交互的 Objective-C++ 类。然后,所有 Objective-C 类都可以保持不变,但会调用 OpenFeint 处理程序类。
Have you followed all of the steps listed on the Integrating the OpenFeint SDK page?
Alternatively, you could create one single class that is Objective-C++ that interfaces with OpenFeint. Then all your Objective-C classes can remain the same but make calls to the OpenFeint handler class.
您是否已将包含或导入 OpenFeint 的所有文件重命名为 .mm ?您还尝试过在构建设置中关闭(或打开)“编译拇指”吗?
Have you renamed all files that include or import OpenFeint to .mm ? Also have you tried turning off (or on) 'compile for thumb' in your build settings?