Replies: 1 comment 1 reply
-
It's probably easier to call https://github.com/yallop/ocaml-ctypes/tree/master/tests/test-funptrs |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Consider the following:
Type
t
represents astruct t *
defined in some C library. In this C code, I somehow get a reference tocb
, and have astruct t *t
available. Now I want tocaml_callback
thiscb
closure, passing int
(the C pointer). Is this possible?When declaring a stub for a function which takes a
t
, the generated C code containsvoid *x2 = CTYPES_ADDR_OF_FATPTR(x1)
, so it appears in the C code doing thecaml_callback
I somehow need to wrap mystruct t
pointer in a "fat pointer" (a record with 3 fields). However, whereCTYPES_FROM_PTR
andCTYPES_TO_PTR
exist, there seems to be no equivalent for these "fat pointers".Am I overlooking something? Or should I somehow not use
unit ptr
and instead try something usingCtypes_ptr.voidp
?Beta Was this translation helpful? Give feedback.
All reactions