The main aim is to easily include C function definitions into ocaml project without any manual writing of bindings or writing C stubs. Just making this process as seamless and easy as possible.
Example:
module Stdlib
[%%include <cstdio.h>]
end
module CHeader
[%%include "path/to/header/file.h"]
end
let () =
Stdlib.printf ~format:"%s" "Hello world!";
CHeader.foo ~input1:"Bar" ~input2:"Baz";
let arr = [2;3;1] in
CHeader.quickSort ~callback:(fun a b -> a < b) ~arr:arr- Single drop in cross platform executable!
- Build in basic types with broad API to satisfy your development needs
- Generated functions keep their argument names
- Low level C api interaction library
- Memory arenas support
Install clang from https://releases.llvm.org/ Have dune with ocaml
I want to avoid as many dependencies as possible and I had some issues on windows platform. Also the verification step of bindings is unnecessary since the bindings are generated automatically from source.
- Because I would have to write bindings for clang parser
- You would get into bootstrapping issue where you would have hard time auditing generated code -> Is the generated code generated wrong because of clang, bindings or logic? Having low level native include avoids that.
- Generated single drop in executable
- Speed