struct access

This topic is 4363 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I've got a structure defined in my menu.h file for some items called item_t. So in my screensaver file I want to create a item of item_t, but the compiler gripes saying "missing storage-class or type specifiers" even when I include my menu.h file. Obviously something I'm doing is wrong, but what? Heres a bit of some code:
menu.h

typedef struct
{
int		w, h;
int		timer1;
int		timer2;
int		Original;

float	x, y, dx, dy;
float	angle, zoom;
bool	paused;
SDL_Surface *img;
}item_t;


ScreenSaver.h

item_t MoveBodyTxt;  <-- Gripes here, why?



Share on other sites
That should fix it.

typedef struct item_t
{
int w, h;
int timer1;
int timer2;
int Original;

float x, y, dx, dy;
float angle, zoom;
bool paused;
SDL_Surface *img;
}item_t;

Share on other sites
This piece of code compiled perfectly on GCC.

Share on other sites
Actually yeah. I just tested your original code on Visual Studio 2005 and it compiled fine.

Share on other sites
You are not compiling what you think you are compiling.

#ifdef COMPILER_ERROR
int x[0];
int z = foozball;
// the odds are one of these two lines will generate a compiler error.
#endif

In ScreenSaver.h:
#define COMPILER_ERROR
#undef COMPILER_ERROR

I'm betting that somehow you aren't including the menu.h you think you are.