Jump to content
  • Advertisement
Sign in to follow this  
marshdabeachy

Compiler issues

This topic is 4229 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

I'm having issues with the compiler (Visual C++ / VS .NET 2003) not being able to handle header includes very well. I've got two classes... Circle and Polygon2D. The Polygon2D class contains a pointer to a Circle, and the Circle class contains a pointer to a Polygon2D. Obviously the Circle class includes the header file for Polygon2D, and vise-versa. The compiler doesn't like that. Circular reference or something, I presume. I get messages saying one of the classes doesn't exist. What's the best way to resolve this?

Share this post


Link to post
Share on other sites
Advertisement
Forward Declarations are what you are looking for.

Basically, when you are making a pointer of a type you don't need the full definition (as found in a header file), you only need a forward declaration of the name of the type.

Share this post


Link to post
Share on other sites
try adding #prgama once
you should see it in VS generated files. I don't have VS handy so I can't tell you what they use exactly but it is something lilke that.

In most other compilers you use something like:
#ifndef FILENAME
#define FILENAME
stuff from file
#endif

this way files are only included once.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!