changeset 7198:b8b8934e9cd6

added robustness against Microsoft's min and max macros
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 08 Nov 2026 12:08:09 +0100
parents 6c2eb64bd793
children 3f0906c82946
files OrthancFramework/Sources/CompatibilityMath.h
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/CompatibilityMath.h	Sun Nov 08 11:06:48 2026 +0100
+++ b/OrthancFramework/Sources/CompatibilityMath.h	Sun Nov 08 12:08:09 2026 +0100
@@ -31,6 +31,23 @@
 #include "Compatibility.h"
 
 
+#if defined(_WIN32)
+/**
+ * <windows.h> defines function-like min/max macros that break
+ * std::min(), std::max(), or std::numeric_limits<T>::max(). Undefine
+ * them right after the include so they cannot interfere with the rest
+ * of the code.
+ **/
+#  include <windows.h>
+#  if defined(min)
+#    undef min
+#  endif
+#  if defined(max)
+#    undef max
+#  endif
+#endif
+
+
 #ifdef __EMSCRIPTEN__
 /*
    Avoid such errors: