Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent macro redefinition

After working some time on my project, this warning begins 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 it's a matter of the order of the include files to solve, because none of these files are mine. My question is if there is a generic way to prevent this or to find which files must to be reordered to avoid this message.

like image 292
Killrazor Avatar asked Oct 13 '10 20:10

Killrazor


2 Answers

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.

like image 135
Mark Ransom Avatar answered Oct 03 '22 17:10

Mark Ransom


Microsoft doesn't generally design headers to be free-standing. Most of the Windows-oriented headers require that you have first included <windows.h>. Except for the dependency on that Mother Of All Headers, usually there are no specific header dependencies so by including <windows.h> first you shouldn't have any problem.

like image 41
Cheers and hth. - Alf Avatar answered Oct 03 '22 16:10

Cheers and hth. - Alf