Giter VIP home page Giter VIP logo

Comments (4)

GoogleCodeExporter avatar GoogleCodeExporter commented on August 16, 2024
The conflicts can be avoided by using #define NOGDI prior to including 
windows.h.

Original comment by [email protected] on 8 Feb 2010 at 3:06

from google-glog.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 16, 2024
WinGDI.h contains the following line:
#define ERROR 0

which of course, eventually causes weird syntax errors.

The NOGDI solution should probably be documented, along with the fact that 
ERROR is
not 0, and one should grep their code for possible misuse.

Those that need GDI should defines NOGDI then manually include the necessary 
headers
with #undef ERROR afterward.
NOGDI should still be defined to prevent other #includes from including WinGDI.h

Original comment by [email protected] on 17 May 2010 at 11:34

from google-glog.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 16, 2024
I added a small section into our document.

http://code.google.com/p/google-glog/source/detail?r=79

Thanks for discussions!

Original comment by [email protected] on 28 May 2010 at 3:23

  • Changed state: Duplicate

from google-glog.

GoogleCodeExporter avatar GoogleCodeExporter commented on August 16, 2024
WIN32_LEAN_AND_MEAN doesn't really help. Or at least not in all VC versions. I 
use MSVC 2008 and <wingdi.h> is included in <windows.h> out of the 
"WIN32_LEAN_AND_MEAN" section so, the only thing that works is NOGDI.

For reducing further confusing I propose adding the following section in 
log_severity.h (just before declaring severity constants):

#ifdef _WIN32
#ifdef ERROR
// If you see this warning then you included <windows.h> which tries to defines 
ERROR macro. To
// avoid odd and unstable compile errors define a project wide macro NOGDI.
//
// Or if you plan using GDI at the very first line of the project add the 
following code:
//
//#include <windows.h>
//#undef ERROR
//#undef RGN_ERROR
//#define RGN_ERROR 0

#define STRING2(x) #x
#define STRING(x) STRING2(x)

#pragma message (__FILE__ "(" STRING(__LINE__) ") : error: ERROR name has 
already been defined")
#undef ERROR
#endif /* ERROR */
#endif /* _WIN32 */

This checking will catch the issue and produce nice VC-style error. Though, if 
one include windows.h after the logging.h there still be a problem. It probably 
makes sense to force definition of NOGDI right after the checking.

Original comment by [email protected] on 8 Nov 2011 at 7:19

from google-glog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.