GP2X Classes


gavinb2k

Still Fresh
Joined
Sep 29, 2007
Messages
40
Hi all,

I'm using Open2X and SDL to just play around at the moment, i have a simple file that has an entry point, sets up SDL and then quits. works fine.

However if i add a basic class to the file just above main entry point, such as:

class testClass{
int a;
int b;
};

i get 3 errors:

Syntax error before testClass
Error before '{' token
Error before '}' token

do i need to change something with the make file, i.e to use g++ instead of gcc, or change a gcc switch, or am i missing something else?

many thanks
 
Parkydr said:
I tried it with open2x and it compiles for me. Maybe there's a problem with the declaration before that class.

I'll try g++ when i get home, all that is before the class declaration is #include "sdl.h" and #include "stdio.h"

ta
 
Last edited by a moderator:
yaustar said:
It should be:
CODE
#include <sdl.h>
#include <cstdio>

Ah...kk i shall try that, it just seemed strange it compiles with no issue if i remove the class declaration?
 
Last edited by a moderator:
yaustar said:
Are you saying:
CODE
testClass{
int a;
int b;
};

compiles fine?
No, sorry the main.cpp compiles with no worries if i remove the class declaration, its only when i add that short class it gives those 3 errors :D
 
Last edited by a moderator:
Are you using "main.c" or "main.cpp", the gcc will try to auto-detect the language based on the extension ...

sorry I missed the:
QUOTE

No, sorry the main.cpp compiles with no worries if i remove the class declaration, its only when i add that short class it gives those 3 errors.
 
Gary Miller said:
Are you using "main.c" or "main.cpp", the gcc will try to auto-detect the language based on the extension ...

sorry I missed the:
QUOTE

No, sorry the main.cpp compiles with no worries if i remove the class declaration, its only when i add that short class it gives those 3 errors.

hmm...will double check, pretty sure its .cpp but was early in the morning and eyes were possibly closed lol
 
Last edited by a moderator:
Quiest said:
Compiles fine for me too o_O
Maybe you are indeed trying to compile it as C and not C++?
lol, wouldnt surprise me looking back, still at work tho so cant test, when will this day end (of course i know that'll be 23:59.59hrs)
 
Last edited by a moderator:
Back
Top