diff --git a/Lib/python/embed.i b/Lib/python/embed.i index 34cb9b92a..505dd9b57 100644 --- a/Lib/python/embed.i +++ b/Lib/python/embed.i @@ -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 +#if __GNUC__ >= 7 +#pragma GCC diagnostic pop +#endif + #ifdef __cplusplus extern "C" #endif diff --git a/Lib/python/pyruntime.swg b/Lib/python/pyruntime.swg index b1033dfbc..74669a74f 100644 --- a/Lib/python/pyruntime.swg +++ b/Lib/python/pyruntime.swg @@ -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 #endif + +#if __GNUC__ >= 7 +#pragma GCC diagnostic pop +#endif %} %insert(runtime) "swigrun.swg"; /* SWIG API */