打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Windows下stdlib.h与glut.h中exit()函数重复定义的解决方案
The Solution for 'redefinition of exit()'in glut.h and stdlib.h

 

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

D:\Program Files\Microsoft VisualStudio .NET2003\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 byopening glut.h and find the definition of exit() function (about line144). Replace them by following. Then rebuild project:


  1. #if defined(_WIN32)  
  2. # ifndef GLUT_BUILDING_LIB  
  3. #if _MSC_VER >= 1200  
  4. _CRTIMP __declspec(noreturnvoid __cdecl exit(int);  
  5. #else  
  6. _CRTIMP void __cdecl exit(int);  
  7. #endif  
  8. # endif  
  9. #else  

 

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

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

 

  1. #if defined(_WIN32)  
  2. # ifndef GLUT_BUILDING_LIB  
  3. #if _MSC_VER >= 1200  
  4. _CRTIMP __declspec(noreturnvoid __cdecl exit(int);  
  5. #else  
  6. _CRTIMP void __cdecl exit(int);  
  7. #endif  
  8. # endif  
  9. #else  

 

    然后重新编译项目即可。

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
c语言中的malloc()包含在哪个库函数中
VC++6.0程序去掉程序对msvcp60.dll的倚赖
MSVC CRT运行库启动代码分析
C语言详解——文件读取
VC常用数据类型列表
'_beginthreadex' : undeclared identifier
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服