Original Post
🔒 Locked
Header file issue?
Advertisement
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:
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 =)
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.
Advertisement