Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Calling C from OCaml and data representation question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Remi Vanicat <remi.vanicat@l...>
Subject: Re: [Caml-list] Calling C from OCaml and data representation question
Vasili Galchin <vasiliocaml@yahoo.com> writes:

> Hello,
>
>     I am working on some run-time library project. I
> have read in the online "OReilly" book the chapter
> where it discusses data representation in particular C
> functions, Long_val and Int_val. Is there really the
> preferred way to handle data representation issues
> from OCaml to C?? The reason I ask is that C is really
> very bad about types like "int" and "long", i.e. these
> types are not portable. It is really better to use
> "unit32", "unit64", etc. If I have a 32 bit entity,
> how can I use Long_val and Int_val safely?

the ocaml specification tell us that an int on a 32 bit platform is
an integer on 31 bit, an int on a 64 bit platform is an integer on 63
bit, and so one. So beware. If you have really a 32 bit entity, may be
you should use the int32 type. There is the "copy_int32" function in
alloc.h and the Int32_val define in mlvalues.h for manipulating them.

-- 
Rémi Vanicat

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners