[ocaml-ctypes] calling a dynamically generated function

Jeremy Yallop yallop at gmail.com
Wed Apr 8 16:42:12 BST 2015


On 8 April 2015 at 16:34, Nicolas Ojeda Bar <no263 at dpmms.cam.ac.uk> wrote:
> I have a value of type `unit ptr` that points to a function with known
> signature.  Is there a way to obtain an OCaml function out of it in order to
> call it ?
>
> In other words, I am looking for a function with signature : `unit ptr -> 'a
> fn -> 'a`.

I think this is what you're looking for:

   # fun c f -> coerce (ptr void) (Foreign.funptr f) c;;
   - : unit Ctypes_static.ptr -> ('a -> 'b) fn -> 'a -> 'b = <fun>


More information about the Ctypes mailing list