views:

160

answers:

2

I've been getting a compile error in Code::Block for an SDL_Surface variable. Strangely enough, this is the first time I have received this kind of error, as I have used this line of code previously and it has worked fine.

One (of several with the same problem) sample line of code that causes this problem is:

extern SDL_Surface *screen;

The resulting error is this:

expected init-declarator before "extern"|
expected `,' or `;' before "extern"|

||=== Build finished: 2 errors, 0 warnings ===|

I tried to understand the error, but I can not tell what it is. Does anyone know what might be wrong?

A: 

It's a wild guess since I don't have much to work with. Do you have all the headers required for SDL_Surface before that extern?

dirkgently
Ya, the header file is #include "SDL.h" and I've used this line on my previous project
@Anoymonous: You've mentioned multiple problems. If this is not the first error that you've hit, try fixing the ones before this one.
dirkgently
A: 

It looks like you're missing the definition of SDL_Surface. Make sure to #include the proper header file in which SDL_Surface is defined. Alternatively, if you're not actually using the screen variable (i.e. you're not accessing any of its fields), you can declare it using an incomplete type as so:

extern struct SDL_Surface *screen;
Adam Rosenfield