Skip to content

Commit

Permalink
Fix -Wregister error on Clang in C++17 mode
Browse files Browse the repository at this point in the history
Suppresses the warning on GCC, Clang, and MSVC.
  • Loading branch information
Kojoley authored and stefanseefeld committed Mar 21, 2019
1 parent 4b01139 commit 6bd6d71
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions include/boost/python/detail/wrap_python.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,38 @@ typedef int pid_t;

#endif // _WIN32

#if defined(__GNUC__)
# if defined(__has_warning)
# define BOOST_PYTHON_GCC_HAS_WREGISTER __has_warning("-Wregister")
# else
# define BOOST_PYTHON_GCC_HAS_WREGISTER __GNUC__ >= 7
# endif
#else
# define BOOST_PYTHON_GCC_HAS_WREGISTER 0
#endif

// Python.h header uses `register` keyword until Python 3.4
#if BOOST_PYTHON_GCC_HAS_WREGISTER
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wregister"
#elif defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable : 5033) // 'register' is no longer a supported storage class
#endif

#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 2 && PY_MICRO_VERSION < 2
# include <boost/python/detail/python22_fixed.h>
#else
# include <Python.h>
#endif

#if BOOST_PYTHON_GCC_HAS_WREGISTER
# pragma GCC diagnostic pop
#elif defined(_MSC_VER)
# pragma warning(pop)
#endif
#undef BOOST_PYTHON_GCC_HAS_WREGISTER

#ifdef BOOST_PYTHON_ULONG_MAX_UNDEFINED
# undef ULONG_MAX
# undef BOOST_PYTHON_ULONG_MAX_UNDEFINED
Expand Down

0 comments on commit 6bd6d71

Please sign in to comment.