Use defined for some preprocessor variables that might be undefined (#2476)

The variables PYBIND11_HAS_OPTIONAL, PYBIND11_HAS_EXP_OPTIONAL, PYBIND11_HAS_VARIANT,
__clang__, __APPLE__ were not checked for defined in a minortity of instances.

If the project using pybind11 sets -Wundef, the warnings will show.

The test build is also modified to catch the problem.
This commit is contained in:
Ciro Santilli
2020-09-10 18:58:26 +01:00
committed by GitHub
parent 621906b3e7
commit b47efd35fb
4 changed files with 7 additions and 7 deletions

View File

@@ -15,7 +15,7 @@
#include <string>
// 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 <boost/variant.hpp>