[ocaml-ctypes] Bind a function with a type external to the library

Jacques-Pascal Deplaix jp.deplaix at gmail.com
Wed Jan 21 22:07:39 GMT 2015


Hi,

I'm trying to bind libmemphis with ctypes and I encounter some problems 
with one function in particular:
https://github.com/LamaUrbain/ocaml-memphis/blob/master/src/memphis_renderer.ml#L55

The function takes a cairo_t in C but in OCaml I would like to use 
Cairo.context.
So I tried by using Obj.magic in the overloading just below (in the code 
linked above) but when I try to use the function it segfaults in some 
random cairo function (memphis_renderer_draw_tile is called before and 
seems to work).

Is there an other way to use an OCaml type (Cairo.context) instead of 
the abstract C type or the problem might comes from somewhere else ?

Cheers,


More information about the Ctypes mailing list