[Cython] Cython code fails to compile with gcc 2.95
Stefan Behnel
stefan_ml at behnel.de
Fri Feb 1 12:06:36 CET 2008
Hi,
I know, that's a pretty old compiler, but I know someone with a Solaris
production setup that still uses it. Here is the compile error he gets:
--------------------------------
src/lxml/lxml.etree.c: In function `__pyx_PyInt_AsLongLong':
src/lxml/lxml.etree.c:110165: parse error before `long'
src/lxml/lxml.etree.c:110167: `val' undeclared (first use in this function)
src/lxml/lxml.etree.c:110167: (Each undeclared identifier is reported only once
src/lxml/lxml.etree.c:110167: for each function it appears in.)
src/lxml/lxml.etree.c: In function `__pyx_PyInt_AsUnsignedLongLong':
src/lxml/lxml.etree.c:110185: parse error before `long'
src/lxml/lxml.etree.c:110187: `val' undeclared (first use in this function)
error: command 'gcc' failed with exit status 1
--------------------------------
The problem lies in the new type conversion functions:
--------------------------------
110156 static INLINE PY_LONG_LONG __pyx_PyInt_AsLongLong(PyObject* x) {
110157 if (PyInt_CheckExact(x)) {
110158 return PyInt_AS_LONG(x);
110159 }
110160 else if (PyLong_CheckExact(x)) {
110161 return PyLong_AsLongLong(x);
110162 }
110163 else {
110164 PyObject* tmp = PyNumber_Int(x); if (!tmp) return
(PY_LONG_LONG)-1;
110165 PY_LONG_LONG val = __pyx_PyInt_AsLongLong(tmp);
110166 Py_DECREF(tmp);
110167 return val;
110168 }
110169 }
110170
110171 static INLINE unsigned PY_LONG_LONG
__pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
110172 if (PyInt_CheckExact(x)) {
110173 long val = PyInt_AS_LONG(x);
110174 if (unlikely(val < 0)) {
110175 PyErr_SetString(PyExc_TypeError, "Negative assignment to
unsigned type.");
110176 return (unsigned PY_LONG_LONG)-1;
110177 }
110178 return val;
110179 }
110180 else if (PyLong_CheckExact(x)) {
110181 return PyLong_AsUnsignedLongLong(x);
110182 }
110183 else {
110184 PyObject* tmp = PyNumber_Int(x); if (!tmp) return
(PY_LONG_LONG)-1;
110185 PY_LONG_LONG val = __pyx_PyInt_AsUnsignedLongLong(tmp);
110186 Py_DECREF(tmp);
110187 return val;
110188 }
110189 }
--------------------------------
So it seems like this line doesn't compile:
--------------------------------
PY_LONG_LONG val = __pyx_PyInt_AsLongLong(tmp);
--------------------------------
Given the error, I would say that "PY_LONG_LONG" gets expanded to the usual
"long long".
Any idea what could go wrong here and what to do about it?
Stefan
More information about the Cython-dev
mailing list