Wrapping C with Python

Uwe Schmitt rocksportrocker at googlemail.com
Tue Aug 5 07:06:56 EDT 2008


On 4 Aug., 15:14, brad <byte8b... at gmail.com> wrote:
> RPM1 wrote:
>
> ...
>
> > Basically you just compile your C code as a regular C code dll.  ctypes
> > then allows you to access the functions in the dll very easily.
>
> Does that work with C++ code too or just C?

It works if the interface of the DLL is C-style, that is you declare
your
functions with 'extern "C" { .... }' around them.
Inside your modules implementation you can use C++ without any
problems.

What works fine too, is f2py from numpy. It targets at wrapping
Fortran
code, but is able to wrap C  code too, see

      http://www.scipy.org/Cookbook/f2py_and_NumPy?action=show

Greetings, Uwe

Greetings, Uwe



More information about the Python-list mailing list