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.
diff --git a/tests/test_stl.cpp b/tests/test_stl.cpp
index 9286357..b230717 100644
--- a/tests/test_stl.cpp
+++ b/tests/test_stl.cpp
@@ -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>