[ocaml-ctypes] Abstract 'a typ

Thomas Braibant thomas.braibant at gmail.com
Mon Mar 9 21:14:36 GMT 2015

Hi list,

I am working on some new bindings for a library which hides the
declaration of a struct. Basically, all the public header defines is

typedef struct foo foo;

All functions of the library return pointers to `foo` or consume
pointers to `foo`.  I reckon that it prevents users of the library to
copy the structure or mess with its members.

I do not know what's the preferred way to handle this situation in
ctypes. I would really like to use `abstract`, but in that particular
case, I should really not be able to provide the size nor the
alignement of the struct. I could use void pointers to implement foo
pointers, but this seem a bit error prone (minor variation: use magic
to expose `unit ptr typ` as `foo ptr typ` with `foo` a fresh type).

Any pointers welcome!


More information about the Ctypes mailing list