Skip to content

Commit 6bd6d71

Browse files
Kojoleystefanseefeld
authored andcommitted
Fix -Wregister error on Clang in C++17 mode
Suppresses the warning on GCC, Clang, and MSVC.
1 parent 4b01139 commit 6bd6d71

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

include/boost/python/detail/wrap_python.hpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,38 @@ typedef int pid_t;
145145

146146
#endif // _WIN32
147147

148+
#if defined(__GNUC__)
149+
# if defined(__has_warning)
150+
# define BOOST_PYTHON_GCC_HAS_WREGISTER __has_warning("-Wregister")
151+
# else
152+
# define BOOST_PYTHON_GCC_HAS_WREGISTER __GNUC__ >= 7
153+
# endif
154+
#else
155+
# define BOOST_PYTHON_GCC_HAS_WREGISTER 0
156+
#endif
157+
158+
// Python.h header uses `register` keyword until Python 3.4
159+
#if BOOST_PYTHON_GCC_HAS_WREGISTER
160+
# pragma GCC diagnostic push
161+
# pragma GCC diagnostic ignored "-Wregister"
162+
#elif defined(_MSC_VER)
163+
# pragma warning(push)
164+
# pragma warning(disable : 5033) // 'register' is no longer a supported storage class
165+
#endif
166+
148167
#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 2 && PY_MICRO_VERSION < 2
149168
# include <boost/python/detail/python22_fixed.h>
150169
#else
151170
# include <Python.h>
152171
#endif
153172

173+
#if BOOST_PYTHON_GCC_HAS_WREGISTER
174+
# pragma GCC diagnostic pop
175+
#elif defined(_MSC_VER)
176+
# pragma warning(pop)
177+
#endif
178+
#undef BOOST_PYTHON_GCC_HAS_WREGISTER
179+
154180
#ifdef BOOST_PYTHON_ULONG_MAX_UNDEFINED
155181
# undef ULONG_MAX
156182
# undef BOOST_PYTHON_ULONG_MAX_UNDEFINED

0 commit comments

Comments
 (0)