English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
C wrappers and callbacks from Ocaml to C and back to Ocaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-08-07 (04:24)
From: Erik de Castro Lopo <mle+ocaml@m...>
Subject: Re: [Caml-list] C wrappers and callbacks from Ocaml to C and back to Ocaml
Goswin von Brederlow wrote:

> Well, you just do. A structure is a value like anything else.

Yes, with a bit of careful debugging I managed to get a bit further
and even managed to extract (in the C code) the Ocaml function from
the Ocaml struct and I think I can call it, but I haven't test that

> What you have to watch out for is the GC.

This is what I was worried about :-).

> If you store the value
> somewhere then you have to tell the GC about it by registering it as a
> new root. And when you are done with it you need to unregister it.

Ah yes, the following two functions in <caml/memory.h>:

    CAMLextern void caml_register_global_root (value *);
    CAMLextern void caml_remove_global_root (value *);

Erik de Castro Lopo