Replies: 2 comments 1 reply
-
Hi, @wjakob. Is this a bug? I encounter the similar problem and tried many ways to pass it, but failed. This is the definition: typedef void (*LLVMFatalErrorHandler)(const char *Reason);
void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler); And binding code: m.def("install_fatal_error_handler", &LLVMInstallFatalErrorHandler, "handler"_a) The error:
|
Beta Was this translation helpful? Give feedback.
-
Many C libraries will invoke your callback with an opaque "context"/"cookie"/variously-named pointer that you provide. You can support these by using a wrapper function and treating the context as a PyObject*:
If you don't have such a user-controlled pointer available, the problem becomes much harder, because you need to generate a separate piece of code (separate function pointer) for every Python callable object you want to support. This is a simple form of JIT compilation and needs platform-specific support. You might be able to use |
Beta Was this translation helpful? Give feedback.
-
I have a c struct that contains a function pointer.
This function pointer is a callback used internally by the c library. I would like the c library to be able to call a python function that I pass into this struct.
How do I write a python function into the c struct function pointer?
I have tried:
.def_rw("PO2SOconfigx", &some_structt::PO2SOconfigx)
Beta Was this translation helpful? Give feedback.
All reactions