views:

660

answers:

4

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?

+1  A: 

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.

Charles Bailey
sorry, I had to type the error by hand (is there a way to copy XCode errors?) it is BrickControlLayer that is the problem. I've correected it in the question.
gargantaun
OK, my second paragraph still applies. You need to use a compiler that understands Objective C or the hybrid Objective C++.
Charles Bailey
I followed the instructions on the Openfeint website, changed the relevant files to .mm and added "Other Link Flags: -ObjC", amongst other thing specified in the Openfeint walkthrough. Although, I still don't understand how it can work fine one minute, and not the next.
gargantaun
A: 

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.

Colin Gislason
yup, I followed all those steps exactly. That's how I got it all working in the first place. That said, I think your solution might be the way to go. Although, it seems to be throwing errors in classes that don't call openfeint, but are included in files that do... one of which being the AppDelegate which needs to initialize Openfeint.
gargantaun
Have you tried doing a Clean and rebuilding?
Colin Gislason
A: 

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?

Joe Cannatti
yup, and tried 'compile for thumb' off an on. No difference.
gargantaun
+1  A: 

Hey, 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

Jason
wowzer, talk about customer support!! To be fair, this has definitely been caused by my inexperience with ObjC, C++ and iPhone dev. I've created a fresh project and built it back up step by step to make sure everything was working as it should be. I've also cleaned up all the header files since there were a few includes hanging around from earlier on in development. I've re-integrated Openfeint (it's boss awesome by the way) and it's compiling fine on the device and the simulator. I think it was a circular include caused by my own ignorance. But now I'm back on track for submitting on monday.
gargantaun
oh, and welcome to Stackoverflow by the way. It is also boss awesome.
gargantaun