Unwanted WinGDI.h header file
I am doing macros like
#define report_msg(type,msg_str).......my_special_##type(......)
#define report_error(msg_str) report_msg(ERROR,msg_str)
It works fine under linux, when I compile with visual studio 2010 express, I see that it gives an error that
error C3861: 'my_special_0': identifier not found
The reason is that "ERROR" is interpreted as 0. And when I use "Go to defination" in MSVC it ββgoes to WinGDI.h
/* Region Flags */
#define ERROR 0
Question: why is this WinGDI.h enabled? How can I fix it without touching the code?
source to share
This is why macros are evil. I've seen cases where TRUE and FALSE are defined with different values ββin different headers. In any decent sized project, it can be tedious to keep track of the title chains. Try
#undef ERROR
#define report_msg(type,msg_str).......my_special_##type(......)
#define report_error(msg_str) report_msg(ERROR,msg_str)
and hopefully the "real" ERROR definitions are not needed after these statements.
source to share
Solution 1: Swap Includes Orders Of Some Headers -> Tedious Task
Solution 2:
Put NOGDI
in a preprocessor. In Visual Studio: Project Properties -> Configuration Properties -> C / C ++ -> Preprocessor -> Preprocessor Definitions -> Add NOGDI
.
Explanation:
Paul pointed me in the right direction. I am not using precompiled headers, so I am not including stdafx.h
. My problem is with Linux and Windows libraries.
In my case, I am using a library that defines an ERROR constant for log messages. For timestamps, ctime.h
enabled which uses Windows.h
/ WinGDI.h
.
source to share