Hi there!
I’m happy to report the release of ocaml-posix version 4.0.0: GitHub - savonet/ocaml-posix: Bindings to the various POSIX APIs
This collection of modules was started some time ago with the goal of centralizing and normalizing the patterns for binding constants, types (including C stuct ) and functions from the POSIX standard using ctypes.
The goal is to offer:
- A common set of tools and practices for structuring and binding using
ctypes. - APIs and modules suitable for low-level
ctypesuse. - High level APIs and modules suitable for direct OCaml use.
- Multi platform compatibility:
*BSD,linux,macosandwindowswhen available. - Cross-platform compilation using
dune’s awesome cross-compilation support when applicable (currently onlyposix-errnoandposix-socket)
With this release, 4 new modules have been added:
posix-errnoto deal with unix error numbers. Although there are some alternatives already existing, this one is a more straight-forward and modern implementation usingdunefor building with cross-compilation and multi-platform support.posix-stat,posix-resourceand the extensiveposix-unistd.
Hopefully these modules can be useful to more developers and provide a common platform for interfacing OCaml programs with system calls in a portable and extensible way!
FAQ:
- Why is this not using
dune’s direct support forctypes?
Cross-compilation support requires running binary compiled for the target (e.g. windows) on the host (e.g. linux) in order to extract specific data points such as C constants values and C struct entries offset. Currently, this is not supported using dune’ builtin ctypes support. However, support for this is being worked on.