[Cython] Recursive structure, typedef

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Dec 2 00:27:52 CET 2008


David Cournapeau wrote:

> Notice how the recursive is referenced through a typedef. In C, this
> is solved by forward declaring the struct through a typedef before the
> struct declaration. But AFAIK, you can't do that in cython.

Not sure about Cython, but the following works in Pyrex:

   cdef struct foo

   ctypedef foo foo_t

   cdef struct foo:
     foo_t *f

i.e. although you can't forward-declare and typedef
in one go, you can forward declare the struct and
then typedef it.


-- 
Greg


More information about the Cython-dev mailing list