[ocaml-ctypes] Defines, and Structs with platform-specific fields

Daniel Bünzli daniel.buenzli at erratique.ch
Mon Oct 20 15:40:13 BST 2014

Le lundi, 20 octobre 2014 à 16:10, Jeremy Yallop a écrit :
> Yet another possibility: you can avoid the need to write C altogether
> by defining the public interface as a module type, defining the
> platform-specific struct definitions as implementations, and using
> first-class modules (or the build system, if you prefer) to pick an
> appropriate definition for the platform.

While Jeremy's approach is sound, I would advise against it from a maintenance point of view.  

These platform specific fields are labelled as *private* fields in the C interface which means that each time libuv makes a new release you will have to manually check that your description of the c struct in your ctypes is still accurate.  

If the libuv project is well managed you can assume public field changes will be documented in release notes so you'll be warned when you need to do changes. However changes to these privates fields are unlikely to be described so it will be more work for you in the long term.  



More information about the Ctypes mailing list