[ocaml-ctypes] calling a dynamically generated function

Nicolas Ojeda Bar no263 at dpmms.cam.ac.uk
Wed Apr 8 16:52:53 BST 2015


Thanks ! That should do it.

Best wishes,
Nicolas

On Wed, Apr 8, 2015 at 4:42 PM, Jeremy Yallop <yallop at gmail.com> wrote:

> 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>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ocaml.org/pipermail/ctypes/attachments/20150408/4e84a95b/attachment.html>


More information about the Ctypes mailing list