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

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

Stefan Brüns
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 <[hidden email]>
---
 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

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt