need help with struct

May 10, 2012 at 5:09pm
i have a problem with my struct, and i cant seem to figure out what to do to fix it :S
here is the code(its in a seperate header file):

1
2
3
4
5
6
7
8
9
10
11
#ifndef TILE_H
#define TILE_H
#include "sdl.h"

struct tiles {
	int id;
	bool solid;
	SDL_Rect clip;
};

#endif 


and here is the errors i get:

1
2
3
tile.h(5): error C2236: unexpected 'struct' 'tiles'. Did you forget a ';'?
tile.h(5): error C2143: syntax error : missing ';' before '{'
tile.h(5): error C2447: '{' : missing function header (old-style formal list?)


what have i done wrong?
May 10, 2012 at 5:38pm
I'd say the problem lies in sdl.h.
May 10, 2012 at 5:42pm
i highly doubt that, as it is a widely used library...and i myself has used it for a long time, without any problems.
May 10, 2012 at 10:51pm
closed account (zb0S216C)
Perhaps tiles is conflicting with another identifier? Or maybe TILE_H has already been defined?

Wazzak
May 11, 2012 at 12:39pm
i have used tiles before without problems. and i tried changing the TILE_H to something else, but it didn't work...
any other ideas?
May 11, 2012 at 12:48pm
Maybe there is an error in the file that includes tiles.h? Does this code compile if you put it in an empty source file?
#include "tiles.h"
May 11, 2012 at 12:54pm
You need to show us the source file that you are trying to compile.
May 11, 2012 at 1:07pm
i tried making a new project, to see if i could get it to work, and it seems like it does work now.

i have no idea what i did wrong, but at least i think i have got it working. luckily i had only gotten like 200-300 lines of code, so i dont loose much work :)
May 11, 2012 at 3:39pm
luckily i had only gotten like 200-300 lines of code

Maybe I'm just a newbie, but isn't 200-300 a lot?
May 11, 2012 at 4:13pm
Maybe I'm just a newbie, but isn't 200-300 a lot?


No.

Anyway, just taking a guess: The header included before tiles.h may have been missing a semicolon. It's hard to say without anything to look at. The snippet posted is fine.
May 18, 2012 at 7:39pm
"Maybe I'm just a newbie, but isn't 200-300 a lot? "

no its not really alot. especially when i no what to write.
Topic archived. No new replies allowed.