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?

+3


source to share


3 answers


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.

+3


source


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

.

+2


source


WinGDI.h

is probably included through Windows.h

from your stdafx.h

. To make sure it is enabled, enable the "Show includes" option here: Project Settings-> Configuration Properties-> C / C ++ -> Advanced-> Show Includes-> Yes and recompile the source.

+1


source







All Articles