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
Wrapping OCaml function returning a variant
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-03-28 (11:33)
From: Joel Reymont <joelr1@g...>
Subject: Wrapping OCaml function returning a variant
Is there an example of returning a variant from OCaml into C somewhere?

It's a regular variant, declared like this

type morpher_output =
   | Success of string
   | Error of string * int * int * int

The other issue is that I don't know how to deal with strings  
allocated in OCaml. Will they be  collected automatically?

The strings _must_ be allocated in OCaml but I can guarantee that  
they will not be modified in the C code. Any suggestions on how to  
deal with this?

	Thanks, Joel