Closed vrotaru closed 8 months ago
I don't know whether it's related to the problem you're seeing, but calling variadic functions is likely to work better using stub generation than via the Foreign
interface, since the C compiler can see the prototype at the point of the call. If you can, I recommend switching to stub generation.
Sorry for the confusion, the error was on my part.
There is a protocol is for object extension and as part of this protocol one has to supply a class_init
function and an instance_init
functions to the C runtime. I was providing those as closure, and Gc.compact ()
war doing what it was supposed to do.
I'm closing the issue.
Here is the relevant part of the code
And here is the error:
And if I remove the![Screenshot from 2023-10-03 10-00-19](https://github.com/yallop/ocaml-ctypes/assets/246236/02f9681d-2644-4223-912c-8d3da791144d)
Gc.compact ();
line it works as expected and creates the preferences dialog. This one:I have looked at the
"src/ctypes-foreign/ctypes_ffi.ml", line 151, characters 16-144
and it tries to de-reference a weak ref and it fails. That's OK.What I do not understand where is the closure which is GC-ed away. And why.
PS. If any more context is needed, I'll be glad to oblige. Unfortunately I do not have a small self-containing example, reproducing it, or I would have attached it.
And
Gc.compact ()
does not seem to have any effect on a similar vararg invocation ofprintf