diff --git a/docs/configuration.md b/docs/configuration.md index 9feadf21..f2b7104e 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -69,6 +69,13 @@ You may also suppress any of these features by using the `_NO_` form, e.g. `CATC All C++11 support can be disabled with `CATCH_CONFIG_NO_CPP11` +# Windows header clutter + +On Windows Catch includes `windows.h`. To minimize global namespace clutter in the implementation file, it defines `NOMINMAX` and `WIN32_LEAN_AND_MEAN` before including it. You can control this behaviour via two macros: + + CATCH_CONFIG_NO_NOMINMAX // Stops Catch from using NOMINMAX macro + CATCH_CONFIG_NO_WIN32_LEAN_AND_MEAN // Stops Catch from using WIN32_LEAN_AND_MEAN macro + --- -[Home](Readme.md) \ No newline at end of file +[Home](Readme.md) diff --git a/include/internal/catch_console_colour_impl.hpp b/include/internal/catch_console_colour_impl.hpp index e3cb9538..ba2a9d1c 100644 --- a/include/internal/catch_console_colour_impl.hpp +++ b/include/internal/catch_console_colour_impl.hpp @@ -41,15 +41,7 @@ namespace Catch { #if defined ( CATCH_CONFIG_COLOUR_WINDOWS ) ///////////////////////////////////////// -#ifndef NOMINMAX -#define NOMINMAX -#endif - -#ifdef __AFXDLL -#include -#else -#include -#endif +#include "catch_windows_h_proxy.h" namespace Catch { namespace { diff --git a/include/internal/catch_platform.h b/include/internal/catch_platform.h index 120ba599..09b91bfb 100644 --- a/include/internal/catch_platform.h +++ b/include/internal/catch_platform.h @@ -10,13 +10,19 @@ #define TWOBLUECUBES_CATCH_PLATFORM_H_INCLUDED #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) -#define CATCH_PLATFORM_MAC +# define CATCH_PLATFORM_MAC #elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED) -#define CATCH_PLATFORM_IPHONE -#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) -#define CATCH_PLATFORM_WINDOWS +# define CATCH_PLATFORM_IPHONE #elif defined(linux) || defined(__linux) || defined(__linux__) -#define CATCH_PLATFORM_LINUX +# define CATCH_PLATFORM_LINUX +#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) +# define CATCH_PLATFORM_WINDOWS +# if !defined(NOMINMAX) && !defined(CATCH_CONFIG_NO_NOMINMAX) +# define CATCH_DEFINES_NOMINMAX +# endif +# if !defined(WIN32_LEAN_AND_MEAN) && !defined(CATCH_CONFIG_NO_WIN32_LEAN_AND_MEAN) +# define CATCH_DEFINES_WIN32_LEAN_AND_MEAN +# endif #endif #endif // TWOBLUECUBES_CATCH_PLATFORM_H_INCLUDED diff --git a/include/internal/catch_timer.hpp b/include/internal/catch_timer.hpp index 2ba709e3..00adfc3b 100644 --- a/include/internal/catch_timer.hpp +++ b/include/internal/catch_timer.hpp @@ -15,7 +15,7 @@ #endif #ifdef CATCH_PLATFORM_WINDOWS -#include +#include "catch_windows_h_proxy.h" #else #include #endif diff --git a/include/internal/catch_windows_h_proxy.h b/include/internal/catch_windows_h_proxy.h new file mode 100644 index 00000000..4f059b4a --- /dev/null +++ b/include/internal/catch_windows_h_proxy.h @@ -0,0 +1,32 @@ +/* + * Created by Martin on 16/01/2017. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#ifndef TWOBLUECUBES_CATCH_WINDOWS_H_PROXY_H_INCLUDED +#define TWOBLUECUBES_CATCH_WINDOWS_H_PROXY_H_INCLUDED + +#ifdef CATCH_DEFINES_NOMINMAX +# define NOMINMAX +#endif +#ifdef CATCH_DEFINES_WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +#endif + +#ifdef __AFXDLL +#include +#else +#include +#endif + +#ifdef CATCH_DEFINES_NOMINMAX +# undef NOMINMAX +#endif +#ifdef CATCH_DEFINES_WIN32_LEAN_AND_MEAN +# undef WIN32_LEAN_AND_MEAN +#endif + + +#endif // TWOBLUECUBES_CATCH_WINDOWS_H_PROXY_H_INCLUDED