On Thu, May 14, 2009 at 11:21 PM, Lisandro Dalcin <[email protected]> wrote:
> Then your Cython definition does not match the C definition. Could you
> try to fake things in the Cython side like below: ?
>
> cdef extern ... :
>    ctypedef struct iovec "struct iovec":
>       void *iov_base
>       size_t iov_len
>
> If this fails, you will likely have to define like this:
>
> cdef extern ... :
>    cdef struct iovec:
>       void *iov_base
>       size_t iov_len
>
> and always use "struct iovec" as the type, like this:
>
> cdef struct iovec *hdr_names=NULL
> hdr_names=<struct iovec*>malloc(total_count * sizeof(struct iovec))
>
>
> Hope any of all this work. If it does not, come back.
>

I tried first with commented version, then the uncommented:

cdef extern from "sys/uio.h":
    # ctypedef struct iovec "struct iovec":
      # void *iov_base
      # size_t iov_len
    cdef struct iovec:
        void *iov_base
        size_t iov_len


With the first, it fails whenever iovecs are declared,  like this:

uint32_t max_pending_trans
char *traffic_class
struct iovec *req_hdrs
                    ^
------------------------------------------------------------

p_types.pxi:130:21: Syntax error in C variable declaration

The faulty line above is a declaration of field inside another struct.


With the second, it compiles, but then my program sigfaults. I should
add that it never sigfaults if I only have one value in the passed in
array of structs, only if there are more.

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

Reply via email to