您的位置:首页 > 其它

Windows下stdlib.h与glut.h中exit()函数重复定义的解决方案

2010-04-28 11:41 344 查看
The Solution for 'redefinition of exit()'
in glut.h and stdlib.h


When develop GLUT projects in Windows system, we
always encounter this problem or like:

D:/Program Files/Microsoft Visual
Studio .NET
2003/Vc7/include/stdlib.h(256) : error C2381: '

exit
' :


redefinition
;
__declspec(noreturn) differs

D:/programs/glut-3.7.6-bin/GL/glut.h(146) : see declaration of
'

exit
'

We could simply solve this problem by
opening glut.h and find the definition of exit() function (about line
144). Replace them by following. Then rebuild project:

#if defined(_WIN32)
# ifndef GLUT_BUILDING_LIB
#if _MSC_VER >= 1200
_CRTIMP __declspec(noreturn) void __cdecl exit(int);
#else
_CRTIMP void __cdecl exit(int);
#endif
# endif
#else


Windows下用到GLUT进行OpenGL开发时,时常会碰到exit()这个函数在stdlib.h与glut.h两个头文件中重复定义的情况,解
决方案如下:

打开glut.h,找到exit()函数定义的地方(144行左右),替换为以下内容:

#if defined(_WIN32)
# ifndef GLUT_BUILDING_LIB
#if _MSC_VER >= 1200
_CRTIMP __declspec(noreturn) void __cdecl exit(int);
#else
_CRTIMP void __cdecl exit(int);
#endif
# endif
#else


然后重新编译项目即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: