error C2381: “exit” : 重定义

    编译OpenGL   Red   Book   的例子时出现错误,

stdlib.h(406)   :   error   C2381:   “exit”:   重定义;__declspec(noreturn)   不同  
  glut.h(146)   :   参见“exit”的声明  

解决方法:#include <GL/glut.h>
                    #include <stdlib.h>
改成:
                    #include <stdlib.h>
                    #include <GL/glut.h>
通过。

OpenGL和C++有不太融合的地方,在include时要让标准C++类库的头文件位于GLUT图形库头文件之前。

原文地址:https://www.cnblogs.com/h694879357/p/14878037.html