[Cython] Question about providing functions to existing C code

Stefan Behnel stefan_ml at behnel.de
Fri Apr 18 15:07:18 CEST 2008


Johannes Wienke wrote:
> There are existing plugins written in C and I
> want to use these plugins in my Python project. The plugins can call
> several functions that the original framework provided. So now I have to
> implement those functions with Python, Cython or whatever. So the
> questions is about how to generate C code that matches an existing
> header file and enables the C-plugins to call Python code.

Ah, ok. Two things here: 2) you will have to transmit the function pointers to
the plugin (likely through a struct) and 1) you have to declare a Cython
function with the same signature that it has in the header file (which is what
you are asking here).

This might help:

http://ldots.org/pyrex-guide/4-functions.html

If not, could you provide an example of such a signature?

Stefan


More information about the Cython-dev mailing list