问题
I remember that the way you order your #include-s matter. Well, I'm in a bit on trouble. I have these two headers:
#include <gl/glfw.h>
#include <gl/glew.h>
If I run that, I get an error saying that gl.h is included before glew.h. But If I reverse the order of those two so that glew.h is first, I get a LOT of errors. I was just thinking of hunting down what the #define-s mean so I could just say for me: #define whatineed 0x0000x.
- How can I fix this problem with the headers arrangement.
- Is the method of hunting and making my defines safe?
回答1:
What sort of errors are you getting when you include the GLEW header first?
The GLEW header defines all the magic necessary to disable the inclusion of most GL headers, so including the GLEW header before the GLFW one should work; should as in I've used this successfully for a number of years on Linux, Windows and Mac OS X with native GCC, Clang, MinGW, Cygwin and VC++. It's even an official FAQ:
http://www.glfw.org/faq.html#can-i-use-extension-loaders-with-glfw
回答2:
The main problem is that glfw.h has an explicit check to test if gl.h has already been included and fail if it has, instead of just carrying on ignoring that "error". I ended up simply commenting that piece of code out of the header on my version of the lib.
来源:https://stackoverflow.com/questions/5768189/gl-h-included-before-glew-but-glfw-needs-gl-h