#error : OpenGL header already included,remove this include, glad already provides it
笔者在编译如下代码时
#include <GLFW/glfw3.h>
#include <glad/glad.h>
vs 报错:error: C1189: #error: OpenGL header already included, remove this include, glad already provides it
原因在于#include <glad/glad.h>语句所处位置不当。GLAD的头文件包含了所需的OpenGL头文件(例如GL/gl.h),因此将GLAD需要置于在其它依赖于OpenGL的头文件(如GLFW)之前。
解决方案:调整#include <glad/glad.h>位置,例如: 将#include <glad/glad.h>置于#include <GLFW/glfw3.h>前