From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p7885OHg022835 for ; Mon, 8 Aug 2011 10:05:24 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtwDALeXP05V2gB5hWdsb2JhbABCmDGPGwEBAQoLCwUWJYFAAQEFgQkLGC4UKIgjvBkOhVlfBJs4iDQ X-IronPort-AV: E=Sophos;i="4.67,336,1309730400"; d="scan'208";a="115245324" Received: from emailfrontal2.citycable.ch ([85.218.0.121]) by mail1-smtp-roc.national.inria.fr with SMTP; 08 Aug 2011 10:03:48 +0200 X-Alinto-smtpauth-localdomain: Yes Received: from seldon (unknown [85.218.93.111]) (Authenticated sender: guillaume.yziquel@citycable.ch) by emailfrontal2.citycable.ch (Postfix) with ESMTPA id F280D20C0E0; Mon, 8 Aug 2011 10:03:35 +0200 (CEST) Received: from yziquel by seldon with local (Exim 4.72) (envelope-from ) id 1QqKoX-00043t-LH; Mon, 08 Aug 2011 10:03:57 +0200 Date: Mon, 8 Aug 2011 10:03:56 +0200 From: Guillaume Yziquel To: caml-list@inria.fr Message-ID: <20110808080356.GD29083@localhost> References: <20110808131504.d9137220d4b4401cc3450e5a@mega-nerd.com> <20110808035322.GI29083@localhost> <20110808174619.00b76d12a02f2c58c10c0108@mega-nerd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20110808174619.00b76d12a02f2c58c10c0108@mega-nerd.com> User-Agent: Mutt/1.5.20 (2009-06-14) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p7885OHg022835 Subject: Re: [Caml-list] Val_int vs caml_copy_nativeint Le Monday 08 Aug 2011 à 17:46:19 (+1000), Erik de Castro Lopo a écrit : > Guillaume Yziquel wrote: > > > What do you mean by "doesn't work" precisely? > > The integer value I assign in the C file (and print out for a > sanity check) ends up as what looks like an address in the > Ocaml code. > > Erik Then I do not see anything wrong if the code snippet you sent. However, when you change Val_int to caml_copy_nativeint, the layout of the tuple is different. With Val_int, you have an integral value in the tuple's field. With caml_copy_nativeint, you have a pointer in the tuple's field. So if you keep the same OCaml code when reading the result value, it's no surprise that the pointer is shown in place of the integer you expected. But this is just guessing. -- Guillaume Yziquel