Not sure what you mean by include guards?  Is this the "if not defined include 
it" constructs?

If so then when I write a class I must do something like:

if not defined GL then {include <GL.h> define GL?

I'm not sure of the syntax yet, but if that is the process, then every class I 
write will have to know that *I* am using the symbol "GL"?

But let's say I am writing a class that may be used in many projects, 
would/should I say at the top of my file something like:
#define MYFILE_INCLUDED  // let users know that my header has been used and 
they can check for this symbol MYFILE_INCLUDED?

(I know this must seem basic, but I come from an environment which takes care 
of all of this for you.)





--- In [email protected], Paul Herring <pauljherr...@...> wrote:
>
> On Mon, Jan 25, 2010 at 1:23 AM, Jimmy Johnson <boxer...@...> wrote:
> > I have a file myClass.h which defines an interface.  The definition depends 
> > on no other classes [headers].
> >
> > The implementation of the member functions for myClass in the cpp file uses 
> > openGL calls so I must include <gl.h>.  (I use a c-wrapper in my main() to 
> > get the correct function type for the c++ objects.)
> > Where should I put the #include <gl.h>, in the header file or the cpp file?
> 
> Does your header file require anything from <gl.h>? If so, put it in
> your header file; if not put it in the cpp file.
> 
> > In my [c-like] main [or root] program I include #myClass.h, but I the main 
> > also uses glut so I must include
> > <glut.h>, which itself includes <gl.h>.  Have I included gl.h twice?
> 
> Yes (presuming glut.h is your header file,) but the contents of that
> file will (should) only be parsed once.
> 
> > Is this bad?
> 
> Not necessarily.
> 
> >If so how do you account for this?
> 
> <gl.h> should have include guards to prevent it being parsed more than once.
> 
> 
> -- 
> PJH
> 
> http://shabbleland.myminicity.com/
> http://www.chavgangs.com/register.php?referer=9375
> http://www.kongregate.com/?referrer=Shabble
>


Reply via email to