Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
A pair of "Interfacing with C" questions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-07-21 (05:43)
From: Robert Roessler <roessler@r...>
Subject: Re: [Caml-list] A pair of "Interfacing with C" questions
dmitry grebeniuk wrote:

> Shalom, Robert.
> ...
> 2) int32 -- good enough.  No limitations and drawbacks of ints/values,
> but it is boxed.

Thanks, dmitry - but this breaks as soon as the software is recompiled 
on a 64-bit implementation (AFAICT). :)

> 3) custom blocks with size sizeof(yourpointertype).  I think it is the
> best alternative: you can attach finalization function (and others, if
> you will need) to blocks.  In this function you can: a) automatically
> deallocate C-side objects, b) write debug info about objects that are
> not closed properly from Caml-side.

Yes, I use custom blocks when their functionality is needed - but here 
I really just want "opaque pointers"... I only need to store them in a 
Caml "value" and be able to hand them back across the Caml/C interface 
on demand.

Robert Roessler