destructor not recognised by Xcode - c++

new to this forum and to programming so please forgive any potential mistakes in my question. I am trying to code a game in c++ using SDL2 and Xcode 6.3.2. In my Game class (see below) Xcode does not recognise my destructor and gives me the error: expected member name or ';' after declaration
I have no idea what is wrong with my destructor or my code in general. My question is simply: What have I done wrong? Thanks in advance!
update:
Narrowed the issue down and ran the code in cpp.sh without any issues. Xcode still gives the error message and I am unable to build because of it. I have tried restarting my computer, deleting the derived data and cleaning the build folder but to no effect.
int main() {
class Game {
public:
Game();
~Game(); //here is the issue
};
}
update 2: Simply removed the non working code and retyped it. The error message did not reappear and the build succeeded. Xcode had probably indeed cached the error message in some strange way.

You need to have written:
Game::~Game(){
}
somewhere at the bottom, outside the class.
Then it will compile fine :)

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.

Embedding Lua to C++ and wxWidgets using Eclipse IDE

I am new to Lua so I am sorry if this is rather an easy question but it is driving me nuts. In my previous thread A simple query on calling Lua 5.2 from C++ I have used an easy C++ code to embed Lua in it. Things worked well but when I transfer that concept to a more complex project, the same code does not work. I have checked many sources but could not find a solution.
Here is my code:
#include "External/include/lua.hpp"
lua_State *luastate =NULL;
IMPLEMENT_APP(ScienceSuitApp);
bool ScienceSuitApp::OnInit()
{
luastate=luaL_newstate();
luaL_openlibs(luastate);
ScienceSuitFrame* frame = new ScienceSuitFrame(0L);
frame->Show();
return true;
}
Now when I try to compile the code, I am getting invalid arguments error for the luaL_openlibs(luastate) line. The error that the compiler gives:
Invalid arguments '
Candidates are:
void luaL_openlibs(*)
' ScienceSuitApp.cpp /ScienceLab line 33 Semantic Error
This is actually happening whenever I call a Lua function such as luaL_dostring etc.. which takes lua_State as parameter. By the way, I am using Eclipse as IDE and wxWidgets as GUI if that should give a clue. Any my configuration for this set up is:
I "think" I have solved the problem. It stems from the fact that Eclipse throws a "semantic error" and not a "syntax error". Therefore, I followed the advice from Eclipse CDT shows semantic errors, but compilation is ok. But now my question is what does it have to do with Indexing in Eclipse IDT? It feels like I am using Eclipse without knowing any of its internals.

Why do I receive a SIGSEGV signal while using the Aria robotics API?

I am using the Aria C++ programming libs for mobile robots (http://robots.mobilerobots.com/wiki/ARIA). I am new to this API so I wanted to start with a simple action class derived from ArAction. Now I tried to develop a small test program (an ArAction) in order to
control a simulated p3dx robot via MobileSim. Development takes place under Ubuntu 10.10, using gcc 4.4.5. Making (compiling) my code works fine, without errors. I can also set the desired speed for example in my ArAction's fire() method, and the simulation is also working as desired.
But, unfortunately, I can't use the ArRobot object attached to the ArAction I am overriding. The problem is that none of the member functions of the ArRobot object seems to work. For example, calling getVel() or getCompass() always returns a zero value. And when I call the hasFrontBumpers() method the program even crashes with the error message "Aria: Received signal 'SIGSEGV'. Exiting.". As soon as I remove this method call and recompile the error is also gone again...
Here is the relevant code that leads to the crash:
ArActionDesired * forward::fire(ArActionDesired d)
{
desiredState.reset();
ArRobot *r = getRobot();
if(r == NULL)
{
printf("ArRobot = NULL\n");
deactivate();
return &desiredState;
}
printf("ok, ArRobot is not NULL, check for bumpers...\n");
r->hasFrontBumpers(); // <-- this leads to the SIGSEV-based "crash"
return &desiredState;
}
Any ideas what I am missing here -- is it a problem with my coding, or with the simulation environment? Thanks in advance for your help!
Kind regards, Matthias
ok, found it out now -- for the records: the Aria libs in version 2.7.2 are based on gcc-3 and libstdc++ 5, but Ubuntu 10.10 (which I am using) is shipped with gcc-4 and libstdc++ 6 per default. So I had to manually install the older versions of both packages, now my code is running fine...
cheers!
Calling hasFrontBumpers() for a p3dx from the fire() works fine for me on a similar Linux platform. If something is wrong, it is not in this method but in the initialization of the system. A reason for the non-moving robot could be that robot.enableMotors() hasn't been called.

strange error in Eclipse

hello everyone I have this snippet of the code:
void* Init(int N) {
Hand * DS = new Hand(N);
return (void*)DS;
//DS is static defined somewhere...
every time when I check in Debugger I receive the same error:
mi_cmd_var_create: unable to create variable objec
can somebody please explain why?
P.S. I know that this implementation of the function is not good, but it is what I have... Constructor of the Hand works perfectly!
This guy with the same problem solved it like:
If you have variables in your watch
window that you later eliminate from
your code then attempt to debug again
this error is generated. The fix is to
also delete the variable from the
watch list. At least this is how it
works in Eclipse Europa.

Problem debugging C++ with an Eclipse based IDE

This is a weird question in that I'm not sure where to start looking.
First of all, I haven't done any C++ programming for the last 10 years so it could be me thats forgotten a few things. Secondly, the IDE I'm using is Eclipse based (which I've never used) and customized for Samsung bada based mobile development (it kicks off an emulator for debugging purposes)
I'm posting my code samples as images because the StackOverflow WYSIWYG editor seems to have a problem parsing C++.
[EDIT] Due to complaints I've edited my question to remove the images. Hope that helps :)
I have the following header file...
#include <FApp.h>
#include <FBase.h>
#include <FGraphics.h>
#include <FSystem.h>
#include <FMedia.h>
using namespace Osp::Media;
using namespace Osp::Graphics;
class NineAcross :
public Osp::App::Application,
public Osp::System::IScreenEventListener
{
public:
static Osp::App::Application* CreateInstance(void);
public:
NineAcross();
~NineAcross();
public:
bool OnAppInitializing(Osp::App::AppRegistry& appRegistry);
private:
Image *_problematicDecoder;
};
...and the following cpp file...
#include "NineAcross.h"
using namespace Osp::App;
using namespace Osp::Base;
using namespace Osp::System;
using namespace Osp::Graphics;
using namespace Osp::Media;
NineAcross::NineAcross()
{
}
NineAcross::~NineAcross()
{
}
Application* NineAcross::CreateInstance(void)
{
// Create the instance through the constructor.
return new NineAcross();
}
bool NineAcross::OnAppInitializing(AppRegistry& appRegistry)
{
Image *workingDecoder;
workingDecoder->Construct();
_problematicDecoder->Construct();
return true;
}
Now, in my cpp file, if I comment out the line that reads _problematicDecoder->Construct();...I'm able to set a breakpoint and happily step over the call to Constuct() on workingDecoder. However, as soon as I uncomment the line that reads _problematicDecoder->Construct();... I end up with the IDE telling me...
"No source available for "Osp::Media::Image::Construct()"
In other words, why can I NOT debug this code when I reference Image *image from a header file?
Any ideas?
Thanks :-)
This usually means you're stepping through some code which you do not posses its source.
I assume here that Osp::Media::Image is a class supplied by Samsung or similar for which you do not have the cpp file. So this means the debugger can't show you the current code line while you're at a function of Osp::Media::Image.
Alternatively, there's a good chance you do have all of the source code for this class, but Eclipse doesn't know where it is. In this case you can add the correct directories under the Debug Configurations window.
Ok, problem solved.
The idea is to first new up an instance of Image like so...
_decoder = new Osp::Media::Image();
And then do _decoder->Construct().
Funny enough, this seems blatantly obvious to me now coming from the C# world, though why the code I posted for workingDecoder works is still somewhat mysterious to me. The fact the sample projects pre-loaded with the bada IDE don't seem to make a call to new() leads me to believe that perhaps those samples are outdated our out of synch.
Either that or I really AM wildly out of the C++ loop.
Anyway thanks so much for the effort guys.
Appreciated :)