On Mon, Jan 25, 2010 at 1:23 AM, Jimmy Johnson <[email protected]> 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
