mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-11-03 21:49:32 +01:00 
			
		
		
		
	Added NOMINMAX and WIN32_LEAN_AND_MEAN defines before including windows.h
This stops the `windows.h` header from defining `min` and `max` macros and including lot of Windows APIs that are not needed by Catch.
This commit is contained in:
		@@ -68,6 +68,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)
 | 
			
		||||
[Home](Readme.md)
 | 
			
		||||
 
 | 
			
		||||
@@ -41,9 +41,12 @@ namespace Catch {
 | 
			
		||||
 | 
			
		||||
#if defined ( CATCH_CONFIG_COLOUR_WINDOWS ) /////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
#ifndef NOMINMAX
 | 
			
		||||
#define NOMINMAX
 | 
			
		||||
#endif
 | 
			
		||||
#  ifdef CATCH_DEFINES_NOMINMAX
 | 
			
		||||
#    define NOMINMAX
 | 
			
		||||
#  endif
 | 
			
		||||
#  ifdef CATCH_DEFINES_WIN32_LEAN_AND_MEAN
 | 
			
		||||
#    define WIN32_LEAN_AND_MEAN
 | 
			
		||||
#  endif
 | 
			
		||||
 | 
			
		||||
#ifdef __AFXDLL
 | 
			
		||||
#include <AfxWin.h>
 | 
			
		||||
@@ -51,6 +54,13 @@ namespace Catch {
 | 
			
		||||
#include <windows.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#  ifdef CATCH_DEFINES_NOMINMAX
 | 
			
		||||
#    undef NOMINMAX
 | 
			
		||||
#  endif
 | 
			
		||||
#  ifdef CATCH_DEFINES_WIN32_LEAN_AND_MEAN
 | 
			
		||||
#    undef WIN32_LEAN_AND_MEAN
 | 
			
		||||
#  endif
 | 
			
		||||
 | 
			
		||||
namespace Catch {
 | 
			
		||||
namespace {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -10,11 +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
 | 
			
		||||
#  define CATCH_PLATFORM_IPHONE
 | 
			
		||||
#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER)
 | 
			
		||||
#define CATCH_PLATFORM_WINDOWS
 | 
			
		||||
#  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
 | 
			
		||||
 
 | 
			
		||||
@@ -15,7 +15,19 @@
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef CATCH_PLATFORM_WINDOWS
 | 
			
		||||
#  ifdef CATCH_DEFINES_NOMINMAX
 | 
			
		||||
#    define NOMINMAX
 | 
			
		||||
#  endif
 | 
			
		||||
#  ifdef CATCH_DEFINES_WIN32_LEAN_AND_MEAN
 | 
			
		||||
#    define WIN32_LEAN_AND_MEAN
 | 
			
		||||
#  endif
 | 
			
		||||
#include <windows.h>
 | 
			
		||||
#  ifdef CATCH_DEFINES_NOMINMAX
 | 
			
		||||
#    undef NOMINMAX
 | 
			
		||||
#  endif
 | 
			
		||||
#  ifdef CATCH_DEFINES_WIN32_LEAN_AND_MEAN
 | 
			
		||||
#    undef WIN32_LEAN_AND_MEAN
 | 
			
		||||
#  endif
 | 
			
		||||
#else
 | 
			
		||||
#include <sys/time.h>
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user