Khronos Public Bugzilla
Bug 686 - gl3.h needs CPP include guard against including gl.h
: gl3.h needs CPP include guard against including gl.h
Status: NEW
Product: OpenGL
Classification: Unclassified
Component: Registry
: unspecified
: PC Windows
: P3 normal
: ---
Assigned To: Jon Leech
:
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-08-08 12:37 PDT by Paul Martz
Modified: 2012-08-08 12:49 PDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Martz 2012-08-08 12:37:05 PDT
The comment block at the top of gl3.h reads as follows:
 * It is not possible to #include both <GL3/gl3.h> and either of
 * <GL/gl.h> or <GL/glext.h> in the same source file.
However, it is in fact possible to include both gl3.h and gl.h, at least on Windows. If both are included, then use of deprecated GL commands (such as glPushAttrib()) doesn't generate a compile error.

To protect against including both files, gl3.h could add an additional CPP include guard. Currently, gl3.h has this:

#ifndef __gl3_h_
#define __gl3_h_

But we'd need to add another guard to protect against includeing both headers:

#ifndef __gl_h_
#define __gl_h_

This would prevent both gl3.h and gl.h from being included. If the user's source code included gl.h first, then gl3.h would be skipped; if the source included gl3.h first, then gl.h would be skipped.

As an alternate fix, the comment block at the top of gl3.h could be clarified to state that it is technically possible to include both headers, but this should be avoided.

It is also possible that this is merely a Windows-specific issue, in which case I apologize for wasting your time. :-)

(Note that glu.h typically includes gl.h indirectly, so the list of files that should not be included with gl3.h should also include glu.h.)
Comment 1 Paul Martz 2012-08-08 12:49:41 PDT
Please replace all uses of "gl3.h" with "glcorearb.h". Thanks.