Suppress -Wregister gcc warnings in Python.h

Such as:
/usr/include/python2.7/unicodeobject.h:534:24: warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]

Closes #2227
This commit is contained in:
William S Fulton 2022-05-27 20:01:57 +01:00
commit 8e3f0fd793
2 changed files with 24 additions and 0 deletions

View file

@ -32,8 +32,20 @@ As far as I know, this module is C++ safe.
#ifndef SWIG_NO_PY_SSIZE_T_CLEAN
#define PY_SSIZE_T_CLEAN
#endif
#if __GNUC__ >= 7
#pragma GCC diagnostic push
#if defined(__cplusplus) && __cplusplus >=201703L
#pragma GCC diagnostic ignored "-Wregister" /* For python-2.7 headers that use register */
#endif
#endif
#include <Python.h>
#if __GNUC__ >= 7
#pragma GCC diagnostic pop
#endif
#ifdef __cplusplus
extern "C"
#endif

View file

@ -14,6 +14,14 @@
#ifndef SWIG_NO_PY_SSIZE_T_CLEAN
#define PY_SSIZE_T_CLEAN
#endif
#if __GNUC__ >= 7
#pragma GCC diagnostic push
#if defined(__cplusplus) && __cplusplus >=201703L
#pragma GCC diagnostic ignored "-Wregister" /* For python-2.7 headers that use register */
#endif
#endif
#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG)
/* Use debug wrappers with the Python release dll */
# undef _DEBUG
@ -22,6 +30,10 @@
#else
# include <Python.h>
#endif
#if __GNUC__ >= 7
#pragma GCC diagnostic pop
#endif
%}
%insert(runtime) "swigrun.swg"; /* SWIG API */