On Tue, Jun 30, 2009 at 9:26 PM, Ondrej Certik<[email protected]> wrote:
>
> However, this assumes some particular form of PyObject_HEAD. Once it
> changes, my code will segfault.
>

Indeed. That changes when you use a debug build of Python (./configure
--with-pydebug).

> So I guess the right way to do this is
> to write my own C header file with the above struct (e.g. using the
> PyObject_HEAD macro) and then just reference it using:
>
> cdef extern from "Python.h":
>    ctypedef void PyTypeObject
>
> cdef extern from "my_header.h":
>    ctypedef struct CDataObject:
>        char *b_ptr
>
> which should always work.
>
> What do you think?
>

Provided that ctypes.h is not a public header, I would do exactly the
same as you...

PS: Can you believe that ctypes, being intended to be a tool for easy
interoperation with C code, does not provide a public C API in order
to let third-party codes to take advantage?


-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to