如何防止宏重定义 [英] How to prevent macro redefinition

查看:1367
本文介绍了如何防止宏重定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中工作一段时间后,此警告开始出现:

  2> Game.cpp 
2> c:\program files\microsoft sdks\windows\v6.0a\include\windef.h(126):warning C4005:'APIENTRY':redefiniciónde macro
2> c:\users\ferran\directo\gameprojects\dev-libs\glfw\include\glfw.h(72):vea ladefiniciónanterior de'APIENTRY'
2> c: \program files\microsoft sdks\windows\v6.0a\include\wingdi.h(23):warning C4005:'WINGDIAPI':redefiniciónde macro
2> c:\users\ferran\directo\gameprojects\dev-libs\glfw\include\glfw.h(88):vea ladefiniciónanterior de'WINGDIAPI'

我确定这是一个问题的包含文件的解决,因为这些文件都不是我的。我的问题是如果有一个通用的方法来防止或找到哪些文件必须重新排序以避免此消息。

解决方案

错误消息本身告诉您错误的顺序。它表示 windef.h wingdi.h 正在重新定义在 glfw中定义的符号.h



在Windows包含文件之后放入 glfw.h p>

after working some time in my project, this warning begin to appear:

2>Game.cpp
2>c:\program files\microsoft sdks\windows\v6.0a\include\windef.h(126) : warning C4005: 'APIENTRY' : redefinición de macro
2>        c:\users\ferran\directo\gameprojects\dev-libs\glfw\include\glfw.h(72) : vea la definición anterior de 'APIENTRY'
2>c:\program files\microsoft sdks\windows\v6.0a\include\wingdi.h(23) : warning C4005: 'WINGDIAPI' : redefinición de macro
2>        c:\users\ferran\directo\gameprojects\dev-libs\glfw\include\glfw.h(88) : vea la definición anterior de 'WINGDIAPI'

I'm sure that is a matter of the order of the include files to solve, because none of this files are mine. My question is if there is a generic way to prevent or to find which files must to be reordered to avoid this message.

解决方案

The error message itself is telling you the incorrect order. It says that windef.h and wingdi.h are redefining symbols that were defined in glfw.h.

Put glfw.h after the Windows include files.

这篇关于如何防止宏重定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆