[ocaml-ctypes] Creating a C wrapper for an OCaml value

EMMA R TURETSKY eturetsky at wisc.edu
Fri Sep 11 18:03:30 BST 2015


This may be a question with an obvious answer, but I'm having trouble understanding the manual.


I have two code bases, one in OCaml and one in C (c++, actually, but I'll just be using "extern 'C'" when needed), that I need to pass information to and from.


I have a Module in the OCaml code and all I want to do is to pass it to a C constructor that will just wrap around it.  I don't ever need to touch the data in C.


What will happen is that eventually the C code will get to a point where it needs to perform some operation on two of these data types.  That operation is all ready written in the OCaml code so I then want to be able to pass  the stored values back into OCaml which will perform the operation needed and create a new module of the same type that will again be returned and wrapped in C.  I'm pretty sure I understand how to call an OCaml function from C, so that isn't an issue.


So I guess the meat of my question is how do I pass a value in OCaml to C and just create a wrapper around it in a way that I can pass the same value back when I call OCaml from C using ctypes?  I feel like this should be simple and obvious from the manual, but my OCaml understanding is very weak.


Any help is appreciated,

Emma
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ocaml.org/pipermail/ctypes/attachments/20150911/648a9f11/attachment.html>


More information about the Ctypes mailing list