[Cython] cimport does not respect .H include order

Stephane DROUARD stephane.drouard at st.com
Fri Nov 21 17:39:13 CET 2008


Hello,

With the following files:

foo.h:
typedef int foo_t;

foo.pxd:
cdef extern from "foo.h":
    ctypedef int foo_t

bar.h:
typedef foo_t bar_t;

bar.pyx:
include "foo.pxd"
cdef extern from "bar.h":
    ctypedef foo_t bar_t

Everything is fine.


But if I now replace "include" by "cimport":
bar.pyx:
from foo cimport *
cdef extern from "bar.h":
    ctypedef foo_t bar_t

It fails at gcc step:
bar.h:1: error: syntax error before "bar_t"

This is because in the latter, Cython generates the #include's in the wrong order:
#include "bar.h"
#include "foo.h"

Cheers,
Stephane
-------------- next part --------------
A non-text attachment was scrubbed...
Name: files.zip
Type: application/octet-stream
Size: 721 bytes
Desc: not available
Url : http://codespeak.net/pipermail/cython-dev/attachments/20081121/70438703/attachment.obj 


More information about the Cython-dev mailing list