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

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?

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

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.

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.

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?

Related

SDL2 ios How to get UIViewController pointer

I'm making a mobile game with SDL2 which will be initially developed for IOS.
I have almost finnished the game development, and now, in order to integrate it with Firebase, I need a pointer to UIViewController.
After reading countless topics, I tried this:
SDL_SysWMinfo systemWindowInfo;
SDL_VERSION (& systemWindowInfo.version);
SDL_GetWindowWMInfo (sdlWindow, & systemWindowInfo))
UIWindow * appWindow = mainWindowWMInfo.info.uikit.window;
UIViewController * rootViewController = appWindow.rootViewController;
But the line "UIViewController * rootViewController = appWindow.rootViewController;" causes this error: "Incomplete definition of type '_UIWindow'"
All topics related to this sample code are at least four years old, and I'm trying hard, but I haven't found any topics talking recently about how to get UIViewController in an SDL2 / ios project.
So, my questions are:
Is the sample code above still working in the current versions of SDL2 or has something changed in the latest version and this sample code no longer works?
If the sample code still works, what can I do wrong to cause this “Incomplete definition of type '_UIWindow'” error?
If this sample code no longer works in SDL2, how can I get a UIViewController pointer in the current version of SDL2?
Any help is welcome because I have been stuck in this problem for days. I've been working on this game for ten months and solving this problem is the last task left to complete it , so I really need to solve this issue.
I solve this problem. Everything is OK in SDL, I was using a .cpp file in this code, but I needed to use .mm file here.
So, when I switched the file name from cpp to mm, the problem has solved.

(iOS) How can I get the UIViewController from a C++ Application?

I need to use a library in my C++ project that needs to call an extern function:
SetGameViewController(UIViewController* gameViewController)
I have zero knowledge of Objective C and iOS yet. I need to get UIViewController and pass it to that function.
So this code should get the UIViewController:
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIViewController *rootViewController = window.rootViewController;
I also added this import:
#if defined(OS_IPHONE)
#import <UIKit/UIKit.h>
#endif
I get compiler errors like:
Expected unqualified-id
Unknown type name 'NSString'
I've started learning Objective C and read a few articles but couldn't get much further than that yet.
So basically my question is how do I basically import and use Objective C code in C++ code so that I can get and use the UIViewController?
Easiest way will be to rename your source file with the extension ".mm" - it will then be compiled as objective-c++, which means you get all the wonders of c++ while still being able to interact with objective-c objects (counted pointers to things 'derived' from NSObject).

Xcode: Impossible to use c++ with Scenekit?

I'm a beginner with Xcode...
I'm trying to use openCV c++ with Scenekit=> to make an AR scene.
Well, I was too optimistic.
1/I started to use the default XCode template for game.=> works!
2/openCV without scenekit=> works
3/ mixing...
I imported some c++ headers in the gameviewController file (basically a UIViewController with scenekit inside).
If I let it so, I get compiler error (cstddef not defined). Fair enough, it's C++ so, from what I read, I just have to rename .m to .mm
But, in this case, I get a full list of linker errors such as Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_SCNAction", referenced from:
=> I guess it is more tricky to mix objective C and C++ but on a simpler project, without Scenekit but with a very similar code otherwise, it worked nicely.
Any clue or guide for mixing them? Should I use swift?
Thanks a lot,
Michael
I just need to add "SceneKit.framework" to Link Binary With Libraries:
Same problem here. I had a pure Objective-C class, simply named "GameViewController.m". To turn it into an Obj-C++ class, change the ".m" to ".mm".
However, just by changing the extension, the linker spat back 13 undefined symbols....
"_OBJC_CLASS_$_SCNTransaction", referenced from: ...
"_OBJC_CLASS_$_SCNFloor", referenced from: ...
"_OBJC_CLASS_$_SCNMaterial", referenced from: ...
etc...
To get around this, just create a different (new) Obj-C++ class, with a .mm extension, and place your C++ code in that class.
Now you can instantiate that new class from the class containing SceneKit calls and call the methods in the new Obj-C++ class.
Inside the GameViewcontroller.m class:
...
scene = [SCNScene sceneNamed:#"art.scnassets/grid.dae"];
kinematics = [[KinematicScene alloc] init];
[kinematics setupCharacters];
...
And inside the new Obj-C++ class (KinematicsScene.mm)
#implementation KinematicScene
{
AI::Location *location;
}
-(id) init
{
self = [super init];
if( self )
{
AI::KinematicSeek* seek = new AI::KinematicSeek[2];
location = new AI::Location[2];
}
return self;
}
-(void) setupCharacters
{
.....
}
... etc ....
#end
This worked for me:
Disable module support [CLANG_ENABLE_MODULES, -fmodules]. This has user experience downsides. Read the online help for this setting before disabling it, and also be aware that if you disable it you will become responsible for hunting down the libraries and frameworks you need to link against, and this can be tedious if you are not an old hand.
Build and (attempt to) link. Add the frameworks and libraries you need to resolve the link errors. I recommend creating a group in your project and directing it to your SDK, then adding the frameworks and libraries relative to that SDK.

Problems with implementing QRCodeReader (ZXing)

So I've followed the steps mentioned here: http://zxing.googlecode.com/svn/trunk/iphone/README
And I made sure everything is alright but yet my QRCodeReader isn't being recognized in myVC.mm file.
This is what's the situation:
The project is put into my own project as described in the link.
I've imported the #import "ZXingWidgetController.h" in the header file and it is being recognized.
I've imported the #import "QRCodeReader.h" in the implementation file (.mm)
Then I alloced them both in a targetmethod of some button like this:
ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:NO];
widController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"qr_code_initialising_bg.png"]];
QRCodeReader* qrcodeReader = [[QRCodeReader alloc] init];
NSSet *readers = [[NSSet alloc ] initWithObjects:qrcodeReader,nil];
[qrcodeReader release];
widController.readers = readers;
[readers release];
[self presentModalViewController:widController animated:YES];
Now it tells me that this is the problem:
QRCodeReader* qrcodeReader = [[QRCodeReader alloc] init];
NSSet *readers = [[NSSet alloc ] initWithObjects:qrcodeReader,nil];
[qrcodeReader release];
It says: Use of undeclared identifier 'QRCodeReader'
Why does it not see my import of the QRCodeReader in the seem .mm
file?
What did I forget that is not in the description that I used?
And most important, how do I fix this to recognize the QRCodeReader?
The straight C++ code (not Objective C++) uses C++ namespaces.
You need to either say zxing::qrcode::QRCodeReader or use using statements like
using namespace zxing;
using namespace zxing::qrcode;
Update:
The code above does bring in the C++ class but there's actually a widget class of the same name which I forgot about. It is an Objective C class that wraps the C++ class and is what you want. Instead of the code above, just #import "QRCodeReader.h" ... which you said you did. I expect the two files of the same name are colliding. Did you set the "recursive" option when including the cpp files? The README says "don't need to" but should probably say "must not". That could cause the cpp file to be included and not the widget version.
I had this exact same problem at the end the solution was kind of easy.
I put the .mm file with "Location" -> "Relative to Project".
Hope this help

How do you call a function using self in cocos2d 0.99.5

Yes I am a begginer. I am reading a book on cocos2d development. The author wrote this book using 0.99.4. In the book, it says to call a function that creates sprites and adds them to an array by using the following code: [self initSpiders];. But when I run this, I get a warning that says "'Gamescene may not respond to'-resetSpiders'". I am assuming that there is an updated way of doing this in the newer version of cocos2d. If there is, I would be thankful if someone could explain the proper way of going about this. If this is the correct way, then what am I doing wrong? Thanks in advance.
In objective-c, an object tells a message to do something:
[someObject doSomething];
Or with an argument:
[someObject doSomethingWithArgument:someValue];
The message you get from the compiler is telling you that the object (eg. "someObject") does not understand what you are telling it to do (doSomething).
To make that compiler warning go away, check the following:
Did you #include the header file of the class your "someObject" is an instance of?
Does that header file in fact have the method you are calling? (including arguments?)
If you are calling a method you wrote, make sure you put that method in the header file. If you are calling a method that someone else wrote, or is part of the OS; make sure you include the header file, then perhaps find the method in the header file and copy/paste it into your code. This will make sure you get the EXACT method signature. These two are not the same:
[self generateSprites]; // note the capitol S
[self generatesprites]; // method names are case sensitive
If you need a better answer, you'll need to post some of your code so that people can see what you're doing wrong.