Dear Jeremy, i changed the representation of zframe_t
type frame type t = frame structure ptr let zframe_t : frame structure typ = structure "_zframe_t" > Although 'zframe_t' is incomplete, 'ptr zframe_t' (i.e. zframe_t*) is > complete, so pointer arithmetic (with +@ etc.) should work as you > expect. I tried this approach with pointer arithmetic (+@), but i still get the Static.IncompleteType exception when i call the destroy function. let destroy (msg : t) = let stub = foreign "zframe_destroy" ((ptr zframe_t) @-> returning int) in stub (msg +@ 0) Another problem is, that the zframe_destroy function expects **zframe_t as input, but with msg +@ 0 i only get *zframe_t. Does it suffice to declare the function like i did above, or do i need another approach? Again, many thanks for your efforts. Florian Jeremy Yallop <[email protected]> wrote: > Dear Florian, > > On 19/05/2014, Florian Pichlmeier <[email protected]> wrote: > > > But now i have encountered a new problem. > > Zeromq uses incomplete types for many data types, > > like the frame type > > typedef struct _zframe_t zframe_t; > > > > On the OCaml side i use void pointer to represent > > these data types, and thats where the problem arose. > > > > The frame destroy function call for example is that > > zframe_destroy (zframe_t **self_p); > > with the corresponding ocaml function > > > > let destroy (msg : t) = > > let stub = foreign "zframe_destroy" (ptr void @-> returning int) in > > stub (msg +@ 0) > > > > The problem is the msg +@ 0 part. > > > > > > The ctypes equivalent of zeromq's incomplete struct declaration is a > call to the 'structure' function without a corresponding call to > 'seal'. For example, you can represent zframe_t as follows: > > (* struct _zframe_t *) > let zframe_t = structure "_zframe_t" > > This allows you to give a more precise type to the zframe_destroy binding: > > let zframe_destroy = foreign "zframe_destroy" > (ptr (ptr zframe_t) @-> returning int) > > Although 'zframe_t' is incomplete, 'ptr zframe_t' (i.e. zframe_t*) is > complete, so pointer arithmetic (with +@ etc.) should work as you > expect. > > I hope that helps, > > Jeremy. > > > _______________________________________________ Ctypes mailing list [email protected] http://lists.ocaml.org/listinfo/ctypes
