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

@@ -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