From e5bbffa84cf0c0768dd681b9aa0133169cca6c58 Mon Sep 17 00:00:00 2001 From: "joanna.wozna.intel" Date: Thu, 23 Jul 2020 13:24:54 +0200 Subject: [PATCH] Add NOMINMAX define due to windows.h max/min macro conflict (#25637) test=develop --- paddle/fluid/framework/io/shell.h | 3 +++ paddle/fluid/memory/detail/system_allocator.cc | 3 +++ paddle/fluid/operators/math/matrix_bit_code.h | 3 +++ paddle/fluid/platform/cpu_info.cc | 2 ++ paddle/fluid/platform/enforce.h | 8 +++++--- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/framework/io/shell.h b/paddle/fluid/framework/io/shell.h index 5b3e9a4df1d..dc486275d6f 100644 --- a/paddle/fluid/framework/io/shell.h +++ b/paddle/fluid/framework/io/shell.h @@ -17,6 +17,9 @@ #include #include #ifdef _WIN32 +#ifndef NOMINMAX +#define NOMINMAX // msvc max/min macro conflict with std::min/max +#endif #include #else #include diff --git a/paddle/fluid/memory/detail/system_allocator.cc b/paddle/fluid/memory/detail/system_allocator.cc index c5b9d88433a..0fbbf405f0b 100644 --- a/paddle/fluid/memory/detail/system_allocator.cc +++ b/paddle/fluid/memory/detail/system_allocator.cc @@ -17,6 +17,9 @@ limitations under the License. */ #ifdef _WIN32 #include +#ifndef NOMINMAX +#define NOMINMAX // msvc max/min macro conflict with std::min/max +#endif #include // VirtualLock/VirtualUnlock #else #include // for mlock and munlock diff --git a/paddle/fluid/operators/math/matrix_bit_code.h b/paddle/fluid/operators/math/matrix_bit_code.h index 7f507999fda..22e5256335c 100644 --- a/paddle/fluid/operators/math/matrix_bit_code.h +++ b/paddle/fluid/operators/math/matrix_bit_code.h @@ -27,6 +27,9 @@ limitations under the License. */ #if defined(_WIN32) #include +#ifndef NOMINMAX +#define NOMINMAX // msvc max/min macro conflict with std::min/max +#endif #include #endif // _WIN32 diff --git a/paddle/fluid/platform/cpu_info.cc b/paddle/fluid/platform/cpu_info.cc index 63760ada2b4..b86fd70c9ae 100644 --- a/paddle/fluid/platform/cpu_info.cc +++ b/paddle/fluid/platform/cpu_info.cc @@ -23,7 +23,9 @@ limitations under the License. */ #include #include #elif defined(_WIN32) +#ifndef NOMINMAX #define NOMINMAX // msvc max/min macro conflict with std::min/max +#endif #include #else #include diff --git a/paddle/fluid/platform/enforce.h b/paddle/fluid/platform/enforce.h index 5d755d8c830..475256826f3 100644 --- a/paddle/fluid/platform/enforce.h +++ b/paddle/fluid/platform/enforce.h @@ -19,9 +19,11 @@ limitations under the License. */ #endif // __GNUC__ #if !defined(_WIN32) -#include // dladdr -#else // _WIN32 -#define NOMINMAX // msvc max/min macro conflict with std::min/max +#include // dladdr +#else // _WIN32 +#ifndef NOMINMAX +#define NOMINMAX // msvc max/min macro conflict with std::min/max +#endif #include // GetModuleFileName #endif -- GitLab