Callbacks with ctypes (How to call a python function from C)

后端 未结 2 1900
轻奢々
轻奢々 2020-12-11 02:28

Is it possible to call a Python function from a C dll function?

We consider this C function:

 void foo( void (*functionPtr)(int,int) , i         


        
2条回答
  •  悲哀的现实
    2020-12-11 02:51

    Use CFUNCTYPE to create a callback type:

    c_callback = CFUNCTYPE(None, c_int, c_int)(callback)
    dll.foo(c_callback, a, b)
    

提交回复
热议问题