Stefan Behnel | 1 Feb 12:05

[Cython] Cython code fails to compile with gcc 2.95

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;
(Continue reading)

Re: [Cython] Cython code fails to compile with gcc 2.95

> 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;
(Continue reading)

Stefan Behnel | 1 Feb 14:32

Re: [Cython] Cython code fails to compile with gcc 2.95

Hi,

Sven Berkvens-Matthijsse wrote:
> The problem is that GCC 2.95 does not follow C99 semantics, and the C
> version that it adheres to does not allow variables to be declared in
> the middle of a block. All variables must be declared at the top of a
> block. In the above case:
> 
> 110164         PyObject* tmp = PyNumber_Int(x); if (!tmp) return (PY_LONG_LONG)-1;
> 110165         PY_LONG_LONG val = __pyx_PyInt_AsLongLong(tmp);
> 
> the 'if' statement on line 110164 terminates the end of the variable
> declarations in the block. Line 110165 tries to declare one in the
> middle of some statements, which was not allowed before C99.

Ah, sure, that makes sense. So here's the obvious fix.

Thanks a lot,
Stefan

Attachment (upstream.bundle): application/octet-stream, 568 bytes
Hi,

Sven Berkvens-Matthijsse wrote:
> The problem is that GCC 2.95 does not follow C99 semantics, and the C
> version that it adheres to does not allow variables to be declared in
> the middle of a block. All variables must be declared at the top of a
> block. In the above case:
(Continue reading)


Gmane