VC++ compile errors when including gl.h

openglvisual c++

Compiling a file that uses OpenGL with Visual C++, when I try to include the gl.h header file I get about 150 unhelpful compile errors:

error C2144: syntax error : 'void' should be preceded by ';'

error C4430: missing type specifier – int assumed. Note: C++ does not support default-int

error C2146: syntax error : missing ';' before identifier 'glAccum'

etc.

Best Answer

Just #include <windows.h> before <gl/gl.h> or <gl/glu.h>. It is needed for some types, such as WINGDIAPI and APIENTRY.

Related Topic