Can I pass a Python “self” object to a C function as c_void_p and cast to original type for use in a callback?
问题 Using ctypes to interface my python3 code with a C API. One of the C functions registers a callback function– i.e. it takes a function pointer to the callback and a void* userdata to be made available in that callback. // typedef and C function in myClibrary.so typedef void(__cdecl *callback_function_type)(void*); int RegCallback(callback_function_type callback_function, void* userbdata); I have successfully defined the required callback function type in python using CFUNCTYPE() , passed an