aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-08-22 11:04:32 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-08-22 11:28:31 +0000
commit6f36c4bba37a5452c039d714b48194f6d23c692e (patch)
tree491472baf52f09b6b36bfa3e5d855771b8c1868a /sources
parentb550b4feb7b6009c1a9d18a604a16844bb9afbc0 (diff)
libshiboken: Undefine slots macros when including Python.h
Avoid potential clashes of Qt's "slots" macro when using compilers that support the push_macro pragmas. Change-Id: I33aaa7f4e11cb235344f3bfecd08b9d5ce434227 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources')
-rw-r--r--sources/shiboken2/libshiboken/sbkpython.h28
1 files changed, 22 insertions, 6 deletions
diff --git a/sources/shiboken2/libshiboken/sbkpython.h b/sources/shiboken2/libshiboken/sbkpython.h
index fbac016eb..28814a68e 100644
--- a/sources/shiboken2/libshiboken/sbkpython.h
+++ b/sources/shiboken2/libshiboken/sbkpython.h
@@ -42,13 +42,29 @@
#include "sbkversion.h"
-#include <Python.h>
-#include <structmember.h>
+// Qt's "slots" macro collides with the "slots" member variables
+// used in some Python structs. For compilers that support push_macro,
+// temporarily undefine it.
+#if defined(slots) && (defined(__GNUC__) || defined(_MSC_VER) || defined(__clang__))
+# pragma push_macro("slots")
+# undef slots
+# include <Python.h>
+# include <structmember.h>
// Now we have the usual variables from Python.h .
-#include "python25compat.h"
-#include "shibokenmacros.h"
-#include "pep384impl.h"
-#include "typespec.h"
+# include "python25compat.h"
+# include "shibokenmacros.h"
+# include "pep384impl.h"
+# include "typespec.h"
+# pragma pop_macro("slots")
+#else
+# include <Python.h>
+# include <structmember.h>
+// Now we have the usual variables from Python.h .
+# include "python25compat.h"
+# include "shibokenmacros.h"
+# include "pep384impl.h"
+# include "typespec.h"
+#endif
#if PY_MAJOR_VERSION >= 3
#define IS_PY3K