Browse Source

Do not define WIN32_LEAN_AND_MEAN if already defined (#1244)

This avoids macro redefinition warnings in environments that define
WIN32_LEAN_AND_MEAN on the compiler command line (-D or /D options).

Thanks @zopsicle
Jorrit Rouwe 11 months ago
parent
commit
0fd3773c1a
3 changed files with 9 additions and 3 deletions
  1. 3 1
      Jolt/Core/JobSystemThreadPool.cpp
  2. 3 1
      Jolt/Core/Semaphore.cpp
  3. 3 1
      Jolt/Core/TickCounter.cpp

+ 3 - 1
Jolt/Core/JobSystemThreadPool.cpp

@@ -11,7 +11,9 @@
 #ifdef JPH_PLATFORM_WINDOWS
 #ifdef JPH_PLATFORM_WINDOWS
 	JPH_SUPPRESS_WARNING_PUSH
 	JPH_SUPPRESS_WARNING_PUSH
 	JPH_MSVC_SUPPRESS_WARNING(5039) // winbase.h(13179): warning C5039: 'TpSetCallbackCleanupGroup': pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception.
 	JPH_MSVC_SUPPRESS_WARNING(5039) // winbase.h(13179): warning C5039: 'TpSetCallbackCleanupGroup': pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception.
-	#define WIN32_LEAN_AND_MEAN
+	#ifndef WIN32_LEAN_AND_MEAN
+		#define WIN32_LEAN_AND_MEAN
+	#endif
 #ifndef JPH_COMPILER_MINGW
 #ifndef JPH_COMPILER_MINGW
 	#include <Windows.h>
 	#include <Windows.h>
 #else
 #else

+ 3 - 1
Jolt/Core/Semaphore.cpp

@@ -9,7 +9,9 @@
 #ifdef JPH_PLATFORM_WINDOWS
 #ifdef JPH_PLATFORM_WINDOWS
 	JPH_SUPPRESS_WARNING_PUSH
 	JPH_SUPPRESS_WARNING_PUSH
 	JPH_MSVC_SUPPRESS_WARNING(5039) // winbase.h(13179): warning C5039: 'TpSetCallbackCleanupGroup': pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception.
 	JPH_MSVC_SUPPRESS_WARNING(5039) // winbase.h(13179): warning C5039: 'TpSetCallbackCleanupGroup': pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception.
-	#define WIN32_LEAN_AND_MEAN
+	#ifndef WIN32_LEAN_AND_MEAN
+		#define WIN32_LEAN_AND_MEAN
+	#endif
 #ifndef JPH_COMPILER_MINGW
 #ifndef JPH_COMPILER_MINGW
 	#include <Windows.h>
 	#include <Windows.h>
 #else
 #else

+ 3 - 1
Jolt/Core/TickCounter.cpp

@@ -9,7 +9,9 @@
 #if defined(JPH_PLATFORM_WINDOWS)
 #if defined(JPH_PLATFORM_WINDOWS)
 	JPH_SUPPRESS_WARNING_PUSH
 	JPH_SUPPRESS_WARNING_PUSH
 	JPH_MSVC_SUPPRESS_WARNING(5039) // winbase.h(13179): warning C5039: 'TpSetCallbackCleanupGroup': pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception.
 	JPH_MSVC_SUPPRESS_WARNING(5039) // winbase.h(13179): warning C5039: 'TpSetCallbackCleanupGroup': pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception.
-	#define WIN32_LEAN_AND_MEAN
+	#ifndef WIN32_LEAN_AND_MEAN
+		#define WIN32_LEAN_AND_MEAN
+	#endif
 #ifndef JPH_COMPILER_MINGW
 #ifndef JPH_COMPILER_MINGW
 	#include <Windows.h>
 	#include <Windows.h>
 #else
 #else