Openfeint caused this: ISO C++ forbids of declaration 'myClass' with no type

1.7k Views Asked by At

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?

4

There are 4 best solutions below

2
On BEST ANSWER

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

3
On

Your error is about BrickController not BrickControlLayer 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.

1
On

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.

0
On

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?