From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id EAA01958; Sat, 6 Mar 2004 04:18:45 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id EAA01918 for ; Sat, 6 Mar 2004 04:18:42 +0100 (MET) Received: from mwinf0903.wanadoo.fr (smtp9.wanadoo.fr [193.252.22.22]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i263IsVS025959 for ; Sat, 6 Mar 2004 04:18:55 +0100 Received: from vanicat.homelinux.org (ca-bordeaux-16-205.w80-8.abo.wanadoo.fr [80.8.88.205]) by mwinf0903.wanadoo.fr (SMTP Server) with ESMTP id 0D6C018000D0 for ; Sat, 6 Mar 2004 04:18:41 +0100 (CET) Received: from moi by vanicat.homelinux.org with local (Exim 4.30) id 1AzSKm-0005zy-Ok for caml-list@inria.fr; Sat, 06 Mar 2004 04:18:40 +0100 To: caml-list@inria.fr Subject: Re: [Caml-list] Calling C from OCaml and data representation question References: <20040306023818.58510.qmail@web41207.mail.yahoo.com> From: Remi Vanicat Mail-Copy-To: never Date: Sat, 06 Mar 2004 04:18:40 +0100 In-Reply-To: <20040306023818.58510.qmail@web41207.mail.yahoo.com> (Vasili Galchin's message of "Fri, 5 Mar 2004 18:38:18 -0800 (PST)") Message-ID: <87hdx2zmr3.dlv@vanicat.homelinux.org> User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 run-time:01 val:01 val:01 alloc:01 mlvalues:01 ocaml:01 ocaml:01 int:01 int:01 writes:01 remi:01 remi:01 vanicat:01 vanicat:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 64 Vasili Galchin 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