summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Anselmi <ma.anselmi@gmail.com>2019-02-12 17:58:56 -0500
committerStefan Behnel <stefan_ml@behnel.de>2019-02-13 21:22:41 +0100
commit47a264701831cc1efdd2b9ce92ee1fb6b1359d73 (patch)
tree15c53a342a2828b14ea867dd87a687c8740ee51a
parent04f5f97f160040692905d414782e40e609a47f93 (diff)
downloadcython-47a264701831cc1efdd2b9ce92ee1fb6b1359d73.tar.gz
Avoid GCC diagnostic pragma if GCC < 4.6
GCC diagnostic pragmas were introduced in GCC 4.6, so augment the GCC compiler check with a version check to avoid compilation errors with GCC < 4.6.
-rw-r--r--Cython/Utility/TypeConversion.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Cython/Utility/TypeConversion.c b/Cython/Utility/TypeConversion.c
index 9cba1b04c..d6d52d629 100644
--- a/Cython/Utility/TypeConversion.c
+++ b/Cython/Utility/TypeConversion.c
@@ -702,6 +702,13 @@ static CYTHON_INLINE PyObject* {{TO_PY_FUNCTION}}({{TYPE}} value, Py_ssize_t wid
// NOTE: inlining because most arguments are constant, which collapses lots of code below
+// GCC diagnostic pragmas were introduced in GCC 4.6
+#ifdef __GNUC__
+#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
+#if GCC_VERSION >= 40600
+#define GCC_DIAGNOSTIC
+#endif
+#endif
static CYTHON_INLINE PyObject* {{TO_PY_FUNCTION}}({{TYPE}} value, Py_ssize_t width, char padding_char, char format_char) {
// simple and conservative C string allocation on the stack: each byte gives at most 3 digits, plus sign
char digits[sizeof({{TYPE}})*3+2];
@@ -711,12 +718,12 @@ static CYTHON_INLINE PyObject* {{TO_PY_FUNCTION}}({{TYPE}} value, Py_ssize_t wid
Py_ssize_t length, ulength;
int prepend_sign, last_one_off;
{{TYPE}} remaining;
-#ifdef __GNUC__
+#ifdef GCC_DIAGNOSTIC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#endif
const {{TYPE}} neg_one = ({{TYPE}}) -1, const_zero = ({{TYPE}}) 0;
-#ifdef __GNUC__
+#ifdef GCC_DIAGNOSTIC
#pragma GCC diagnostic pop
#endif
const int is_unsigned = neg_one > const_zero;