You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am getting a runtime error ("libffi does not support passing arrays") when trying to pass an Ocaml function to a C library, where the type of the function uses a structure containing an array field.
In more detail: I am trying to pass an OCaml function to a C library, where the function to be passed takes a struct with an array:
typedef struct { const void *data[2] ... } Blah
and the prototype of the callback in the C library is something like:
With stub generation I can create the OCaml type for the struct. In the OCaml I am creating a type for the function to be passed to the C library as follows:
let data_field = Array.init 2 (fun i -> F.field blah "data") (ptr void))`
I think that's likely to work. Whether you actually need to work around libffi's support for structs with array members depends on whether you actually need to pass OCaml functions to C. If all of your function pointers are created in C code then it'd be better to use static_funptr in place of funptr everywhere.
I am getting a runtime error ("libffi does not support passing arrays") when trying to pass an Ocaml function to a C library, where the type of the function uses a structure containing an array field.
In more detail: I am trying to pass an OCaml function to a C library, where the function to be passed takes a struct with an array:
typedef struct { const void *data[2] ... } Blah
and the prototype of the callback in the C library is something like:
typedef enum VisitResult (*Visitor)(Blah, Blah, void*)
With stub generation I can create the OCaml type for the struct. In the OCaml I am creating a type for the function to be passed to the C library as follows:
let visitor_type = Ctypes.(blah @-> blah @-> (ptr void) @-> returning visit_result)
but when I try to do the coercion trick (mentioned in #364) on the above between funptr and static_funptr:
coerce (Foreign.funptr vistor_type) (static_funptr visitor_type) ocaml_callback_fn
I get a runtime exception being thrown:
Fatal error: exception Ctypes_static.Unsupported("libffi does not support passing arrays")
My bindings compile fine but at runtime I get the error message above: is there a way to fix this?
The text was updated successfully, but these errors were encountered: