Skip to content

Commit 8e3f0fd

Browse files
committed
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 swig#2227
1 parent 7f009ed commit 8e3f0fd

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

Lib/python/embed.i

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,20 @@ As far as I know, this module is C++ safe.
3232
#ifndef SWIG_NO_PY_SSIZE_T_CLEAN
3333
#define PY_SSIZE_T_CLEAN
3434
#endif
35+
36+
#if __GNUC__ >= 7
37+
#pragma GCC diagnostic push
38+
#if defined(__cplusplus) && __cplusplus >=201703L
39+
#pragma GCC diagnostic ignored "-Wregister" /* For python-2.7 headers that use register */
40+
#endif
41+
#endif
42+
3543
#include <Python.h>
3644

45+
#if __GNUC__ >= 7
46+
#pragma GCC diagnostic pop
47+
#endif
48+
3749
#ifdef __cplusplus
3850
extern "C"
3951
#endif

Lib/python/pyruntime.swg

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
#ifndef SWIG_NO_PY_SSIZE_T_CLEAN
1515
#define PY_SSIZE_T_CLEAN
1616
#endif
17+
18+
#if __GNUC__ >= 7
19+
#pragma GCC diagnostic push
20+
#if defined(__cplusplus) && __cplusplus >=201703L
21+
#pragma GCC diagnostic ignored "-Wregister" /* For python-2.7 headers that use register */
22+
#endif
23+
#endif
24+
1725
#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG)
1826
/* Use debug wrappers with the Python release dll */
1927
# undef _DEBUG
@@ -22,6 +30,10 @@
2230
#else
2331
# include <Python.h>
2432
#endif
33+
34+
#if __GNUC__ >= 7
35+
#pragma GCC diagnostic pop
36+
#endif
2537
%}
2638

2739
%insert(runtime) "swigrun.swg"; /* SWIG API */

0 commit comments

Comments
 (0)