Jump to content
  • Advertisement
Sign in to follow this  
M4rtin

Header file issue?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
It wouldn't have worked when you put it in the header, there was no translation unit actually being compiled that included Objects.h. :)

Edit: Please don't edit out the original question from a post. It makes it hard for people to understand what all our replies are about. :(

Share this post


Link to post
Share on other sites
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 =)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!