GLUT 退出重定义错误 [英] GLUT exit redefinition error
问题描述
在我的简单 OpenGL 程序中,我收到有关退出重新定义的以下错误:
In my simple OpenGL program I get the following error about exit redefinition:
1>c:program filesmicrosoft visual studio 8vcincludestdlib.h(406) : error C2381: 'exit' : redefinition; __declspec(noreturn) differs
1> c:program filesmicrosoft visual studio 8vcplatformsdkincludeglglut.h(146) : see declaration of 'exit'
我正在使用 Nate Robins 的 GLUT for Win32 并收到此错误Visual Studio 2005 或 Visual C++ 2005(速成版).此错误的原因是什么,我该如何解决?
I'm using Nate Robins' GLUT for Win32 and get this error with Visual Studio 2005 or Visual C++ 2005 (Express Edition). What is the cause of this error and how do I fix it?
推荐答案
原因:
随最新版本的 Visual Studio 一起提供的 stdlib.h 对 exit() 函数的定义不同(且相互冲突).它与 glut.h 中的定义相冲突.
The stdlib.h which ships with the recent versions of Visual Studio has a different (and conflicting) definition of the exit() function. It clashes with the definition in glut.h.
解决方案:
用 stdlib.h 中的定义覆盖 glut.h 中的定义.将 stdlib.h 行放在代码中的 glut.h 行上方.
Override the definition in glut.h with that in stdlib.h. Place the stdlib.h line above the glut.h line in your code.
#include <stdlib.h>
#include <GL/glut.h>
这篇关于GLUT 退出重定义错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!