[PyQt] [PATCH 1/5] Add SIP_NULLPTR/SIP_OVERRIDE compatibility macros

Stefan Brüns stefan.bruens at rwth-aachen.de
Sat Sep 29 15:27:45 BST 2018


To allow using nullptr throughout the generated code while staying
backwards compatible for C and older C++ compilers, use SIP_NULLPTR
as a proxy. Likewise for override/SIP_OVERRIDE.

Signed-off-by: Stefan Brüns <stefan.bruens at rwth-aachen.de>
---
 sipgen/gencode.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/sipgen/gencode.c b/sipgen/gencode.c
index ca76761..58fc35e 100644
--- a/sipgen/gencode.c
+++ b/sipgen/gencode.c
@@ -608,6 +608,24 @@ static void generateInternalAPIHeader(sipSpec *pt, moduleDef *mod,
 "#include <QThread>\n"
             );
 
+    /* Add some convenience macros to make code forward/backwards compatible. */
+    prcode(fp,
+"\n"
+"#ifndef SIP_NULLPTR\n"
+"#if __cplusplus >= 201103L\n"
+"#define SIP_NULLPTR nullptr\n"
+"#define SIP_OVERRIDE override\n"
+"#elif defined _MSVC_LANG\n"
+"#define SIP_NULLPTR nullptr\n"
+"#define SIP_OVERRIDE override\n"
+"#else\n"
+"#define SIP_NULLPTR 0\n"
+"#define SIP_OVERRIDE\n"
+"#endif\n"
+"#endif\n"
+"\n"
+          );
+
     /* Define the qualifiers. */
     noIntro = TRUE;
 
-- 
2.19.0



More information about the PyQt mailing list