From 0e4392100878d2e7bd9f5a9f17bbec39f9c7b173 Mon Sep 17 00:00:00 2001 From: HongyuJia Date: Mon, 13 Feb 2023 15:47:41 +0800 Subject: [PATCH] [Fix Compile Error] Fix copysign compile error on Windows (#50387) * fix copysign compile error on Windows * fix more files' macro --- paddle/fluid/framework/io/shell.h | 4 ++++ paddle/fluid/pybind/const_value.h | 4 ++++ paddle/fluid/pybind/eager.cc | 4 ++++ paddle/fluid/pybind/eager.h | 4 ++++ paddle/fluid/pybind/eager_functions.cc | 4 ++++ paddle/fluid/pybind/eager_math_op_patch.cc | 4 ++++ paddle/fluid/pybind/eager_method.cc | 4 ++++ paddle/fluid/pybind/eager_properties.cc | 4 ++++ paddle/fluid/pybind/eager_py_layer.cc | 4 ++++ paddle/fluid/pybind/eager_utils.cc | 4 ++++ paddle/fluid/pybind/eager_utils.h | 4 ++++ paddle/fluid/pybind/io.h | 4 ++++ paddle/fluid/pybind/protobuf.h | 4 ++++ paddle/fluid/pybind/pybind_variant_caster.h | 4 ++++ 14 files changed, 56 insertions(+) diff --git a/paddle/fluid/framework/io/shell.h b/paddle/fluid/framework/io/shell.h index c571302cc00..487c2aa95d0 100644 --- a/paddle/fluid/framework/io/shell.h +++ b/paddle/fluid/framework/io/shell.h @@ -21,6 +21,10 @@ #ifndef NOMINMAX #define NOMINMAX // msvc max/min macro conflict with std::min/max #endif +// Avoid a problem with copysign defined in pyconfig.h on Windows. +#ifdef copysign +#undef copysign +#endif #include #else #include diff --git a/paddle/fluid/pybind/const_value.h b/paddle/fluid/pybind/const_value.h index 2fab3160d1d..b4c3b861a80 100644 --- a/paddle/fluid/pybind/const_value.h +++ b/paddle/fluid/pybind/const_value.h @@ -14,6 +14,10 @@ limitations under the License. */ #pragma once #include +// Avoid a problem with copysign defined in pyconfig.h on Windows. +#ifdef copysign +#undef copysign +#endif #include "paddle/fluid/platform/enforce.h" #include "pybind11/pybind11.h" diff --git a/paddle/fluid/pybind/eager.cc b/paddle/fluid/pybind/eager.cc index d7977a1a644..2e7fc1d2e47 100644 --- a/paddle/fluid/pybind/eager.cc +++ b/paddle/fluid/pybind/eager.cc @@ -12,6 +12,10 @@ limitations under the License. */ #include "paddle/fluid/pybind/eager.h" #include +// Avoid a problem with copysign defined in pyconfig.h on Windows. +#ifdef copysign +#undef copysign +#endif #include #include diff --git a/paddle/fluid/pybind/eager.h b/paddle/fluid/pybind/eager.h index 8a4a42b82a2..5b4a637c609 100644 --- a/paddle/fluid/pybind/eager.h +++ b/paddle/fluid/pybind/eager.h @@ -11,6 +11,10 @@ limitations under the License. */ #pragma once #include +// Avoid a problem with copysign defined in pyconfig.h on Windows. +#ifdef copysign +#undef copysign +#endif #include "paddle/fluid/eager/hooks.h" #include "paddle/fluid/eager/pylayer/py_layer_node.h" diff --git a/paddle/fluid/pybind/eager_functions.cc b/paddle/fluid/pybind/eager_functions.cc index e1a05017858..97343b51142 100644 --- a/paddle/fluid/pybind/eager_functions.cc +++ b/paddle/fluid/pybind/eager_functions.cc @@ -16,6 +16,10 @@ typedef SSIZE_T ssize_t; #endif #include +// Avoid a problem with copysign defined in pyconfig.h on Windows. +#ifdef copysign +#undef copysign +#endif #include #include diff --git a/paddle/fluid/pybind/eager_math_op_patch.cc b/paddle/fluid/pybind/eager_math_op_patch.cc index ef8ff4d6c1c..fa38a40f8fb 100644 --- a/paddle/fluid/pybind/eager_math_op_patch.cc +++ b/paddle/fluid/pybind/eager_math_op_patch.cc @@ -16,6 +16,10 @@ typedef SSIZE_T ssize_t; #endif #include +// Avoid a problem with copysign defined in pyconfig.h on Windows. +#ifdef copysign +#undef copysign +#endif #include #include diff --git a/paddle/fluid/pybind/eager_method.cc b/paddle/fluid/pybind/eager_method.cc index 34132e199e7..c6051a7f046 100644 --- a/paddle/fluid/pybind/eager_method.cc +++ b/paddle/fluid/pybind/eager_method.cc @@ -16,6 +16,10 @@ typedef SSIZE_T ssize_t; #endif #include +// Avoid a problem with copysign defined in pyconfig.h on Windows. +#ifdef copysign +#undef copysign +#endif #include #include diff --git a/paddle/fluid/pybind/eager_properties.cc b/paddle/fluid/pybind/eager_properties.cc index c328b1258cd..e8fc670c491 100644 --- a/paddle/fluid/pybind/eager_properties.cc +++ b/paddle/fluid/pybind/eager_properties.cc @@ -10,6 +10,10 @@ See the License for the specific language governing permissions and limitations under the License. */ // disable numpy compile error #include +// Avoid a problem with copysign defined in pyconfig.h on Windows. +#ifdef copysign +#undef copysign +#endif #include #include diff --git a/paddle/fluid/pybind/eager_py_layer.cc b/paddle/fluid/pybind/eager_py_layer.cc index 89bad2bfc92..28c1f179bc4 100644 --- a/paddle/fluid/pybind/eager_py_layer.cc +++ b/paddle/fluid/pybind/eager_py_layer.cc @@ -10,6 +10,10 @@ See the License for the specific language governing permissions and limitations under the License. */ // disable numpy compile error #include +// Avoid a problem with copysign defined in pyconfig.h on Windows. +#ifdef copysign +#undef copysign +#endif #include #include diff --git a/paddle/fluid/pybind/eager_utils.cc b/paddle/fluid/pybind/eager_utils.cc index b3ed1df9570..835a27ed995 100644 --- a/paddle/fluid/pybind/eager_utils.cc +++ b/paddle/fluid/pybind/eager_utils.cc @@ -12,6 +12,10 @@ limitations under the License. */ #include "paddle/fluid/pybind/eager_utils.h" #include +// Avoid a problem with copysign defined in pyconfig.h on Windows. +#ifdef copysign +#undef copysign +#endif #include #include diff --git a/paddle/fluid/pybind/eager_utils.h b/paddle/fluid/pybind/eager_utils.h index 063e14903cf..3b6cb53dc0f 100644 --- a/paddle/fluid/pybind/eager_utils.h +++ b/paddle/fluid/pybind/eager_utils.h @@ -16,6 +16,10 @@ typedef SSIZE_T ssize_t; #endif #include +// Avoid a problem with copysign defined in pyconfig.h on Windows. +#ifdef copysign +#undef copysign +#endif #include "paddle/fluid/eager/hooks.h" #include "paddle/fluid/framework/lod_tensor.h" diff --git a/paddle/fluid/pybind/io.h b/paddle/fluid/pybind/io.h index 10c42582283..4930f06fadc 100644 --- a/paddle/fluid/pybind/io.h +++ b/paddle/fluid/pybind/io.h @@ -20,6 +20,10 @@ typedef SSIZE_T ssize_t; #endif #include +// Avoid a problem with copysign defined in pyconfig.h on Windows. +#ifdef copysign +#undef copysign +#endif #include "paddle/fluid/pybind/pybind_variant_caster.h" diff --git a/paddle/fluid/pybind/protobuf.h b/paddle/fluid/pybind/protobuf.h index 93064de7d92..c0b2849fd7f 100644 --- a/paddle/fluid/pybind/protobuf.h +++ b/paddle/fluid/pybind/protobuf.h @@ -19,6 +19,10 @@ limitations under the License. */ typedef SSIZE_T ssize_t; #endif #include +// Avoid a problem with copysign defined in pyconfig.h on Windows. +#ifdef copysign +#undef copysign +#endif #include #include diff --git a/paddle/fluid/pybind/pybind_variant_caster.h b/paddle/fluid/pybind/pybind_variant_caster.h index 2a25990944d..4aa4fee280a 100644 --- a/paddle/fluid/pybind/pybind_variant_caster.h +++ b/paddle/fluid/pybind/pybind_variant_caster.h @@ -14,6 +14,10 @@ limitations under the License. */ #pragma once #include +// Avoid a problem with copysign defined in pyconfig.h on Windows. +#ifdef copysign +#undef copysign +#endif #include -- GitLab