[Pyrex] Cannot cdef __init__?

Andrew Bennetts andrew-pyrex at puzzling.org
Sun Jan 18 08:00:44 CET 2004


[originally sent privately]

On Sat, Jan 17, 2004 at 09:12:41PM -0800, Paul Prescod wrote:
> Does this variant do what you want?

For this example, yes.

For some reason it's not working for me when the struct is external:

--- foo.h ---

struct pair {
        int x;
        int y;
};

------

--- footest.pyx ---
cdef extern from "foo.h":
    ctypedef struct pair

cdef class Pair:
    cdef pair *p

# ... the rest as you had it

------

Pyrex generates a .c file without problems, but it won't compile:

    pyrex_init_test2.c:38: error: syntax error before "pair"

The offending code is

struct __pyx_obj_16pyrex_init_test2_Pair {
  PyObject_HEAD
  pair (*p);   /* <--- this is line 38 */
};

Any idea what I'm doing wrong?

-Andrew.





More information about the Pyrex mailing list