Dear Nick, I think if you split your code into two functors: one for retrieving struct layout and one for binding functions then things will work out better. The code you've posted only deals with struct layout, so I'll make some suggestions for removing the function binding parts to get it working.
On 6 February 2015 at 09:45, Nick Betteridge <[email protected]> wrote: > I've been trying to get enums/constant working and have been having a > problem in matching types: [...] > module Bindings > (F : sig type _ fn > val foreign : string -> ('a -> 'b) Ctypes.fn -> ('a -> 'b) fn > end) (S : Cstubs.Types.TYPE) = struct You only need the second functor argument (S) here, so you can change the above to: module Bindings (S : Cstubs.Types.TYPE) = struct > open F Make this open S This should fix the type mismatch error. > the generator: [...] > Cstubs.write_ml ml_fmt ~prefix:"libchannel_" (module Bindings); > Format.fprintf c_fmt "%s@\n" c_headers; > Cstubs.write_c c_fmt ~prefix:"libchannel_" (module Bindings); Cstubs.write_ml and Cstubs.write_c are for foreign function bindings. There's a corresponding operation, Cstubs_structs.write_c, for generating code to retrieve struct layout. If you remove the call to Cstubs.write_ml and replace the last line with Cstubs_structs.write_c c_fmt (module Bindings); then you should get a little further. Kind regards, Jeremy. _______________________________________________ Ctypes mailing list [email protected] http://lists.ocaml.org/listinfo/ctypes
