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
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 (10:28)
From: malc <malc@p...>
Subject: Re: [Caml-list] A pair of "Interfacing with C" questions
On Thu, 21 Jul 2005, Jacques Garrigue wrote:

> From: Robert Roessler <roessler@rftp.com>
>> 1) in wrapping a large widget with multiple interfaces using
>> "strings", I sometimes allow the widget to copy a C-string into a
>> Caml-allocated string - INCLUDING "overwriting" the terminating zero
>> byte with zero... I wanted to make sure this was not seen as a major
>> problem.
> No problem currently: for C compatibility all ocaml strings have a 0
> after their end. Nobody can give "future" guarantees, but if there is
> a change at this level, I assume this would be well publicised.
>> 2) this is about "future-proofing" (at the source level) code which
>> interfaces with external [foreign] components and needs to store and
>> pass around "opaque pointers": what is the best base Caml data type to
>> use?
>> I currently use
>> type opaque_ptr = int32
>> I assume the other choices include int64, nativeint, or even int.
> If you look at mlvalues.h you will see that nativeint is define as
> long int. So this should be the natural format for a pointer.

I don't think so, Win64 ABI has sizeof(long) == 4 and sizeof(void *) == 8.