strange error: conflicting types (due to implicit function declaration)

528 views
Skip to first unread message

Jake Vanderplas

unread,
Feb 14, 2013, 11:43:50 PM2/14/13
to cython...@googlegroups.com
Hi,
I'm having trouble compiling a Cython script with extension types and overloaded inline methods. I've managed to boil the problem down to a minimal example which reproduces the error: it consists of a short pxd file, pyx file, and setup script, all shown at the end of this message.  Cython parses the files with no problems, but gcc throws this error on the resulting code:

$> python setup.py build_ext --inplace
running build_ext
cythoning test.pyx to test.c
building 'test' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c test.c -o build/temp.linux-x86_64-2.7/test.o
test.c: In function ‘__pyx_pf_4test_test_func’:
test.c:626:3: warning: implicit declaration of function ‘__pyx_f_4test_7Derived_func’ [-Wimplicit-function-declaration]
test.c: At top level:
test.c:648:29: error: conflicting types for ‘__pyx_f_4test_7Derived_func’
test.c:626:15: note: previous implicit declaration of ‘__pyx_f_4test_7Derived_func’ was here
error: command 'gcc' failed with exit status 1

I don't have a deep enough knowledge of gcc to understand what the problem must be, and google searches haven't proven helpful.
By the way, I am using:

>$ cython --version
Cython version 0.16
>$ gcc --version
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3

Any help would be appreciated.  Thanks,
   Jake


-----------------------------------------------------------
# test.pxd
cdef class Base:
    cdef void func(self)

cdef class Derived(Base):
    cdef inline void func(self):
        pass
------------------------------------------------------------
# test.pyx
cdef class Base:
    cdef void func(self):
        pass

cdef class Derived(Base):
    pass

def test_func():
    cdef Derived d = Derived()
    d.func()
------------------------------------------------------------
# setup.py
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

setup(cmdclass = {'build_ext': build_ext},
      name="test",
      version='1.0',
      ext_modules=[Extension("test", ["test.pyx"])])
------------------------------------------------------------

Lars Buitinck

unread,
Feb 15, 2013, 6:43:10 AM2/15/13
to cython...@googlegroups.com
2013/2/15 Jake Vanderplas <jak...@gmail.com>:
> I'm having trouble compiling a Cython script with extension types and
> overloaded inline methods. I've managed to boil the problem down to a
> minimal example which reproduces the error: it consists of a short pxd file,
> pyx file, and setup script, all shown at the end of this message. Cython
> parses the files with no problems, but gcc throws this error on the
> resulting code:

A quick look at the C code reveals the problem: the C counterpart to
test_func appears before that of Derived.func, so the latter is not
properly declared in the former. The same thing happens without the
inline declaration (Cython 0.18).

--
Lars Buitinck
Scientific programmer, ILPS
University of Amsterdam

Jake Vanderplas

unread,
Feb 15, 2013, 7:38:35 PM2/15/13
to cython...@googlegroups.com
Lars,
Yes, I'd guess this is the source of the problem.
So am I correct to say this is a bug in Cython?  Cython is producing C code here which fails to compile on gcc.
   Jake


--
Lars Buitinck
Scientific programmer, ILPS
University of Amsterdam

--

---
You received this message because you are subscribed to the Google Groups "cython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cython-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Lars Buitinck

unread,
Feb 16, 2013, 6:28:26 AM2/16/13
to cython...@googlegroups.com
2013/2/16 Jake Vanderplas <jak...@gmail.com>:
> Yes, I'd guess this is the source of the problem.
> So am I correct to say this is a bug in Cython? Cython is producing C code
> here which fails to compile on gcc.

Yes, this is a bug. That code doesn't abide by C's declaration rules.
I'm not familiar enough with Cython internals to know where to hunting
for it, though.

Stefan Behnel

unread,
Feb 16, 2013, 9:07:32 AM2/16/13
to cython...@googlegroups.com
Lars Buitinck, 16.02.2013 12:28:
> 2013/2/16 Jake Vanderplas:
>> Yes, I'd guess this is the source of the problem.
>> So am I correct to say this is a bug in Cython? Cython is producing C code
>> here which fails to compile on gcc.
>
> Yes, this is a bug. That code doesn't abide by C's declaration rules.
> I'm not familiar enough with Cython internals to know where to hunting
> for it, though.

This might help in general:

http://wiki.cython.org/HackerGuide#Gettingstarted

Stefan

Reply all
Reply to author
Forward
0 new messages