diff --git a/include/pybind11/stl.h b/include/pybind11/stl.h index 6c2bebda8..721bb669f 100644 --- a/include/pybind11/stl.h +++ b/include/pybind11/stl.h @@ -289,7 +289,7 @@ template struct optional_caster { PYBIND11_TYPE_CASTER(T, _("Optional[") + value_conv::name + _("]")); }; -#if PYBIND11_HAS_OPTIONAL +#if defined(PYBIND11_HAS_OPTIONAL) template struct type_caster> : public optional_caster> {}; @@ -297,7 +297,7 @@ template<> struct type_caster : public void_caster {}; #endif -#if PYBIND11_HAS_EXP_OPTIONAL +#if defined(PYBIND11_HAS_EXP_OPTIONAL) template struct type_caster> : public optional_caster> {}; @@ -369,7 +369,7 @@ struct variant_caster> { PYBIND11_TYPE_CASTER(Type, _("Union[") + detail::concat(make_caster::name...) + _("]")); }; -#if PYBIND11_HAS_VARIANT +#if defined(PYBIND11_HAS_VARIANT) template struct type_caster> : variant_caster> { }; #endif diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 54f13fd54..e59c75ce8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -216,7 +216,7 @@ function(pybind11_enable_warnings target_name) target_compile_options(${target_name} PRIVATE /W4) elseif(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Intel|Clang)" AND NOT PYBIND11_CUDA_TESTS) target_compile_options(${target_name} PRIVATE -Wall -Wextra -Wconversion -Wcast-qual - -Wdeprecated) + -Wdeprecated -Wundef) endif() if(PYBIND11_WERROR) diff --git a/tests/test_operator_overloading.cpp b/tests/test_operator_overloading.cpp index f3c2eaafa..d176c4644 100644 --- a/tests/test_operator_overloading.cpp +++ b/tests/test_operator_overloading.cpp @@ -88,11 +88,11 @@ std::string abs(const Vector2&) { // Here, we suppress the warning using `#pragma diagnostic`. // Taken from: https://github.com/RobotLocomotion/drake/commit/aaf84b46 // TODO(eric): This could be resolved using a function / functor (e.g. `py::self()`). - #if (__APPLE__) && (__clang__) + #if defined(__APPLE__) && defined(__clang__) #if (__clang_major__ >= 10) && (__clang_minor__ >= 0) && (__clang_patchlevel__ >= 1) #pragma GCC diagnostic ignored "-Wself-assign-overloaded" #endif - #elif (__clang__) + #elif defined(__clang__) #if (__clang_major__ >= 7) #pragma GCC diagnostic ignored "-Wself-assign-overloaded" #endif diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp index 928635788..b230717d2 100644 --- a/tests/test_stl.cpp +++ b/tests/test_stl.cpp @@ -15,7 +15,7 @@ #include // Test with `std::variant` in C++17 mode, or with `boost::variant` in C++11/14 -#if PYBIND11_HAS_VARIANT +#if defined(PYBIND11_HAS_VARIANT) using std::variant; #elif defined(PYBIND11_TEST_BOOST) && (!defined(_MSC_VER) || _MSC_VER >= 1910) # include