diff --git a/include/stdex/compat.hpp b/include/stdex/compat.hpp index 03d7d2c5b..27f81a0ef 100644 --- a/include/stdex/compat.hpp +++ b/include/stdex/compat.hpp @@ -8,7 +8,7 @@ #include #include #ifdef _WIN32 -#include +#include "windows.h" #include #endif #include diff --git a/include/stdex/math.hpp b/include/stdex/math.hpp index 4d2e000f2..10279ba08 100644 --- a/include/stdex/math.hpp +++ b/include/stdex/math.hpp @@ -7,7 +7,7 @@ #include "compat.hpp" #ifdef _WIN32 -#include +#include "windows.h" #include #include #endif diff --git a/include/stdex/stream.hpp b/include/stdex/stream.hpp index 31d0a581b..7ba8b1d04 100644 --- a/include/stdex/stream.hpp +++ b/include/stdex/stream.hpp @@ -15,7 +15,7 @@ #include #include #if defined(_WIN32) -#include +#include "windows.h" #include #include #include diff --git a/include/stdex/string.hpp b/include/stdex/string.hpp index 94e7aa0ff..5ae029cc0 100644 --- a/include/stdex/string.hpp +++ b/include/stdex/string.hpp @@ -14,7 +14,7 @@ #include #include #if defined(_WIN32) -#include +#include "windows.h" #include #elif defined(__APPLE__) #include diff --git a/include/stdex/system.hpp b/include/stdex/system.hpp index a06012a36..f1488e6bf 100644 --- a/include/stdex/system.hpp +++ b/include/stdex/system.hpp @@ -7,7 +7,7 @@ #include "compat.hpp" #ifdef _WIN32 -#include +#include "windows.h" #include #include #else diff --git a/include/stdex/windows.h b/include/stdex/windows.h new file mode 100644 index 000000000..eaa2ca343 --- /dev/null +++ b/include/stdex/windows.h @@ -0,0 +1,24 @@ +/* + SPDX-License-Identifier: MIT + Copyright © 2023 Amebis +*/ + +#pragma once + +// Windows.h #defines min and max, which collides with std::min and std::max. +// Not only the collision problem, #defining min and max is plain wrong as it +// causes multiple evaluations of parameter expressions. + +#ifndef NOMINMAX +#define NOMINMAX +#endif + +#include + +// In case somebody #included before us without #defining NOMINMAX +#ifdef min +#undef min +#endif +#ifdef max +#undef max +#endif