On Mon, Apr 27, 2009 at 9:58 AM, Lisandro Dalcin <[email protected]> wrote:
> What does not work? Cython or the C compiler?
>
> I really do not like these generic "ctypedef void* FOO". I would do this:
>
> cdef extern from "header.h":
>   cdef struct struct_FOO "FOO":
>      pass
>   ctypedef struct_FOO* FOO
>
>
> Now, you said the C example does "something like":
>
> static FOO s_foo=NULL;
>
> Are you sure it does that? In such case, it should work. If not,
> please provide us more info about the Cython or C compiler failure...

I tried the following:

cdef extern from "mylib.h":
  cdef struct struct_FOO "FOO":
    pass
  ctypedef struct_FOO* FOO
  int mylib_func(FOO* c)

cdef FOO s_foo
s_foo=NULL
mylib_func(&s_foo)

Cython does not complain. gcc gives a warnings: assignment from
incompatible pointer type
gcc completes fine, but when I run my code, I get a seg fault at that
last function call..

Thanks a lot and please do excuse my ignorance, it's been very long
time since I did C and pointers, got spoiled with Python.

Mohamed.
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to