diff --git a/include/utpp/utpp.h b/include/utpp/utpp.h index 36a660a..42f2772 100644 --- a/include/utpp/utpp.h +++ b/include/utpp/utpp.h @@ -20,12 +20,23 @@ #define UTPP_MUST_UNDEF_LEAN_AND_MEAN #endif +#ifndef NOMINMAX +#define NOMINMAX +#define UTPP_MUST_UNDEF_NOMINMAX +#endif + #include #ifdef UTPP_MUST_UNDEF_LEAN_AND_MEAN #undef UTPP_MUST_UNDEF_LEAN_AND_MEAN #undef WIN32_LEAN_AND_MEAN #endif + +#ifdef UTPP_MUST_UNDEF_NOMINMAX +#undef UTPP_MUST_UNDEF_NOMINMAX +#undef NOMINMAX +#endif + #endif #ifdef _MSC_VER diff --git a/sample/sample.cpp b/sample/sample.cpp index d9da753..686bf6a 100644 --- a/sample/sample.cpp +++ b/sample/sample.cpp @@ -639,4 +639,14 @@ TEST_MAIN (int argc, char** argv) // Check that utpp.h didn't #include in a // way that prevents using WinSock2.h. #include + +// Check that #including has not polluted global +// namespace with windows.h's own min() and max() macros. +#include +static void f() { + int a = 1, b = 2; + int c = std::min(a, b); + (void)c; +} + #endif