Easier to wrap C or C++ libraries?

Thomas Heller theller at python.net
Sun Feb 15 09:45:10 EST 2009


Christian Heimes schrieb:
> Hrvoje Niksic schrieb:
>> "Diez B. Roggisch" <deets at nospam.web.de> writes:
>> 
>>> The answer is easy: if you use C, you can use ctypes to create a
>>> wrapper - with pure python, no compilation, no platform issues.
>> 
>> The last part is not true.  ctypes doesn't work on 64-bit
>> architectures, nor does it work when Python is built with non-gcc Unix
>> compilers
> 
> ctypes works on 64bit systems, too. However it's a pain in the ... back
> to write code with ctypes that works across all platforms. I used to use
> ctypes for wrapper but eventually I switched to Cython.
> 

I have plans to add the types from the ansi-c standard to ctypes, like these:

stddef.h: ptrdiff_t, size_t, wchar_t
signal.h: sig_atomic_t
stdio.h: FILE, fpos_t, stderr, stdout, stdin
stdlib.h: div_t, ldiv_t
time.h: clock_t, time_t, struct tm

Do you think that would have helped for writing cross-platform wrappers?

Thomas



More information about the Python-list mailing list