From 625c6760107b673e92685f02db9200fb9a2ff383 Mon Sep 17 00:00:00 2001 From: Orange Date: Thu, 21 Aug 2025 00:17:59 +0300 Subject: [PATCH] Fixes MSVC redefinition of min/max Adds a compiler definition for MSVC to prevent redefinition of min/max macros by the Windows SDK. Removes unnecessary undef directives in color.hpp as the NOMINMAX definition now handles the issue. --- .idea/workspace.xml | 8 ++++---- CMakeLists.txt | 5 +++++ include/omath/color.hpp | 8 -------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 08ddd13..1c34a9f 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -39,9 +39,9 @@ - - - + + + diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b76979..886d316 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,6 +102,11 @@ elseif (OMATH_THREAT_WARNING_AS_ERROR) target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -Werror) endif () +# Windows SDK redefine min/max via preprocessor and break std::min and std::max +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + target_compile_definitions(${PROJECT_NAME} INTERFACE NOMINMAX) +endif () + target_include_directories(${PROJECT_NAME} PUBLIC $ # Use this path when building the project diff --git a/include/omath/color.hpp b/include/omath/color.hpp index 4172062..f620807 100644 --- a/include/omath/color.hpp +++ b/include/omath/color.hpp @@ -8,14 +8,6 @@ #include "omath/vector4.hpp" #include -#ifdef max -#undef max -#endif - -#ifdef min -#undef min -#endif - namespace omath { struct Hsv