Skip to main content
gamedev.net
🔒 Locked

Header file issue?

Started by M4rtin Dec 23, 2008 at 3:39 PM 2 replies 750+ views
Original Post
M4rtin
M4rtin
Never mind. I forgot to include a SDL header in the header. Not sure why it worked when I put it in 1 header though.
Lawl_Rock
Lawl_Rock
Is the move function actually empty? It may be something in there.
Erik Rufelt
Erik Rufelt
The compiler doesn't seem to know about SDL_Surface yet. You must either include the SDL header in your header, or before your header in the cpp-file (which isn't as good, since this way you will always be depending on that).

Since you use a pointer it's enough to tell the compiler that SDL_Surface is a class, which is recommended since your header won't require the SDL header in that case.
You do this by just adding the line:
class SDL_Surface;

before your Unit class definition. The compiler doesn't actually need to know what the SDL_Surface class is, as long as you use a pointer, it only needs to know that it's the address to some class called SDL_Surface. You still need to include the SDL header in any cpp-file where you actually use the members of the class pointed to.

EDIT: Oh way too late, you solved it while I was typing =)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.