Thomas Heller schrieb: > Eugen Wintersberger schrieb: >> Hi there >> I want to use ctypes in connection with C functions that use complex >> datatypes defined in the C99 standard. Does someone know a simple way >> how to implement this? Are there any plans to integrate the C99 complex >> data types in the ctypes module? > > I have investigated the complex data types a bit and came to the conclusion > that libffi (which ctypes is based upon) would have to be extended to > support these complex types.
I think that depends on what kind of support you want to provide. For passing _Complex values as parameters or receiving them as results, it's certainly necessary to have libffi support. OTOH, if you only want to support _Complex as the field type of a struct or an array, you can do so without libffi support. To write a field at address p with the values r and i, do *(double complex*)p = r * i*I; To fetch the real and imaginary part of a field at address p, do creal(*(double complex*)p) cimag(*(double complex*)p) Likewise for float complex values (and long double complex, if you want to support that). Whether such a limited version would be of any use (e.g. to the OP), I don't know. Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list