From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id A39FCBC6C for ; Thu, 17 Jan 2008 19:41:55 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAL8wj0fAXQImh2dsb2JhbACQFwEBAQgKKYEUnBU X-IronPort-AV: E=Sophos;i="4.24,303,1196636400"; d="scan'208";a="6863670" Received: from discorde.inria.fr ([192.93.2.38]) by mail1-smtp-roc.national.inria.fr with ESMTP; 17 Jan 2008 19:41:54 +0100 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m0HIfpQC012726 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 17 Jan 2008 19:41:54 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAOMvj0dQRFuw/2dsb2JhbACRaZwS X-IronPort-AV: E=Sophos;i="4.24,303,1196636400"; d="scan'208";a="21434863" Received: from furbychan.cocan.org ([80.68.91.176]) by mail4-smtp-sop.national.inria.fr with ESMTP; 17 Jan 2008 19:41:52 +0100 Received: from rich by furbychan.cocan.org with local (Exim 4.63) (envelope-from ) id 1JFZgU-0003ps-Lm; Thu, 17 Jan 2008 18:41:50 +0000 Date: Thu, 17 Jan 2008 18:41:50 +0000 To: Oliver Bandel Cc: caml-list@inria.fr Subject: Re: [Caml-list] Give back a Pair from C to OCaml? Message-ID: <20080117184150.GA14335@annexia.org> References: <1200583973.478f7525e7a5a@webmail.in-berlin.de> <9d3ec8300801170743k509a7c4wa9d8f490118a9653@mail.gmail.com> <1200594739.478f9f33aa51f@webmail.in-berlin.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1200594739.478f9f33aa51f@webmail.in-berlin.de> User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Miltered: at discorde with ID 478FA16F.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 0100,:01 bandel:01 camlprim:01 camlprim:01 oreilly-book:01 gcc:01 -wall:01 ocaml:01 int's:01 unboxed:01 val:01 val:01 .....:98 wrote:01 On Thu, Jan 17, 2008 at 07:32:19PM +0100, Oliver Bandel wrote: > For example I can use "CAMLprim value (.....){...}" > or I can throw out "CAMLprim" (which is, what I found in the > OReilly-book). It's not really a good idea to "throw out" CAMLprim. It expands to something useful on Windows. > Also "value x" or "int x" are working as C-parameters > of a function. But an OCaml-int is not the same like a > C-int, so I would expect gcc throw out at least a warning. > I have added "-Wall", but no warning there. value <> int. On normal 64 bit architectures it's defined as a long, but basically they are not interchangable and you should always use 'value' when you mean an OCaml value. > Possibly that's because what is mentioned in "18.2", > that int's are "value". > But there is no distinction between the OCaml-ints and the > machine's C-ints in that text. Is "an unboxed integer" meant > to be a machine's native int, 32 Bits or 64 Bits, depending on the > machine?. Can it be given as parameter and return value as it is? No. A Caml int is not represented the same way as a C int. This doesn't matter because you should be using the macros supplied to convert between the two representations, Val_int, Int_val, Long_val, Unsigned_long_val etc. Rich. -- Richard Jones Red Hat