I am using the new dune ctypes stanza.
I was wondering if it was possible to have a constant generation pass, before the type generation pass, in order to use the constants to build types.
for example, consider this C code:
#define SIZE 42
struct foo {
int array [SIZE];
};
I would like to do something like this:
module Types(T : Ctypes.TYPE) = struct
type foo
let size = T.constant "SIZE" T.int64_t
let foo : foo Ctypes.structure T.typ = T.structure "foo"
...
let () = T.seal foo
end
but to use the array field:
let arr = T.field foo "array" (T.array (Int64.of_int size) T.int) (* error *)
seems impossible, as size
is still a int64 T.const
…
Do I have to go back from the fantastic dune ctypes stanza to custom rules, or is there a trick I am missing?