matus-chochlik / oglplus

OGLplus is a collection of open-source, cross-platform libraries which implement an object-oriented facade over the OpenGL® (version 3 and higher) and also OpenAL® (version 1.1) and EGL (version 1.4) C-language APIs. It provides wrappers which automate resource and object management and make the use of these libraries in C++ safer and more convenient.
http://oglplus.org/
Boost Software License 1.0
492 stars 72 forks source link

std::numeric_limits<T>::max()) conflicts with max macro defined in Windows.h #135

Closed htmlboss closed 7 years ago

htmlboss commented 7 years ago

Hi again!

I just wanted to let you know that I stumbled across a nasty macro conflict on line 51 of size.hpp: if(v > X(std::numeric_limits<T>::max())). (http://stackoverflow.com/a/27443191/2231969)

Windows has a macro called max in Windows.h that does this:

#ifndef max
#define max(a,b)            (((a) > (b)) ? (a) : (b))
#endif

And naturally my VS Intellisense got confused and thought it was referring to the STL member...but the compiler said otherwise :P

All I needed to do was just add to the top of size.hpp:

#ifdef max
    //#undef max
#endif

Not sure if this is the only instance of that function call or if this the best way to get around it. I know...WinAPI is dumb >.>