Commit d8542f75 authored by Michael Anselmi's avatar Michael Anselmi

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.
parent bce20eb6
...@@ -710,6 +710,13 @@ static CYTHON_INLINE PyObject* {{TO_PY_FUNCTION}}({{TYPE}} value, Py_ssize_t wid ...@@ -710,6 +710,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 // 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) { 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 // simple and conservative C string allocation on the stack: each byte gives at most 3 digits, plus sign
char digits[sizeof({{TYPE}})*3+2]; char digits[sizeof({{TYPE}})*3+2];
...@@ -719,12 +726,12 @@ static CYTHON_INLINE PyObject* {{TO_PY_FUNCTION}}({{TYPE}} value, Py_ssize_t wid ...@@ -719,12 +726,12 @@ static CYTHON_INLINE PyObject* {{TO_PY_FUNCTION}}({{TYPE}} value, Py_ssize_t wid
Py_ssize_t length, ulength; Py_ssize_t length, ulength;
int prepend_sign, last_one_off; int prepend_sign, last_one_off;
{{TYPE}} remaining; {{TYPE}} remaining;
#ifdef __GNUC__ #ifdef GCC_DIAGNOSTIC
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion" #pragma GCC diagnostic ignored "-Wconversion"
#endif #endif
const {{TYPE}} neg_one = ({{TYPE}}) -1, const_zero = ({{TYPE}}) 0; const {{TYPE}} neg_one = ({{TYPE}}) -1, const_zero = ({{TYPE}}) 0;
#ifdef __GNUC__ #ifdef GCC_DIAGNOSTIC
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif
const int is_unsigned = neg_one > const_zero; const int is_unsigned = neg_one > const_zero;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment