[ocaml-ctypes] Help with strings

Jeremy Yallop yallop at gmail.com
Thu Dec 28 20:38:06 GMT 2017


Dear John,

On 28 December 2017 at 19:31, john skaller <skaller at internode.on.net> wrote:
> I think the point is, why generate C just so you can generete
> platform dependent Ocaml, when you can just generate the C
> and bind to the C you generated?

I'm not sure it's exactly what you have in mind, but there is
something rather like this on the roadmap:

   https://github.com/ocamllabs/ocaml-ctypes/issues/266
   https://github.com/ocamllabs/ocaml-ctypes/pull/296

As you say, the new approach will provide better support for cross compilation.

> You have to compile the C
> in both cases, but in the second case you just link to it,
> and you have to link to the foreign library anyhow.

That's the usual situation, but it's occasionally useful to bind
static elements (struct & union definitions, compile-time constants,
etc.) only, in which case it's preferable to pull all the
layout/constant information into the generated OCaml code, and avoid
the need to link in C.  For example, the Profuse library, which
implements the FUSE protocol, does exactly that:

   https://github.com/effuse/profuse/tree/master/lib_gen

Kind regards,

Jeremy


More information about the Ctypes mailing list