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 p78HOTxW018680 for ; Mon, 8 Aug 2011 19:24:32 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArMBAOcaQE7UGyoCkWdsb2JhbABCmByPChQBAQEBCQsLBxQDIoFAAQEEAVMlBgsLIRYPCQMCAQIBRRMIAQGHaQK+BYZHBJMChQiDLoE5hns X-IronPort-AV: E=Sophos;i="4.67,338,1309730400"; d="scan'208";a="115299423" Received: from smtp2-g21.free.fr ([212.27.42.2]) by mail1-smtp-roc.national.inria.fr with ESMTP; 08 Aug 2011 19:24:31 +0200 Received: from [192.168.1.3] (unknown [82.237.71.191]) by smtp2-g21.free.fr (Postfix) with ESMTP id 17B034B017C for ; Mon, 8 Aug 2011 19:24:24 +0200 (CEST) Message-ID: <4E401BC7.5040001@inria.fr> Date: Mon, 08 Aug 2011 19:24:23 +0200 From: Xavier Leroy User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110617 Thunderbird/3.1.11 MIME-Version: 1.0 To: caml-list@inria.fr References: <20110808131504.d9137220d4b4401cc3450e5a@mega-nerd.com> <20110808035322.GI29083@localhost> <20110808174619.00b76d12a02f2c58c10c0108@mega-nerd.com> <20110808080356.GD29083@localhost> In-Reply-To: <20110808080356.GD29083@localhost> X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Caml-list] Val_int vs caml_copy_nativeint On 08/08/2011 10:03 AM, Guillaume Yziquel wrote: > 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. [...] 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. This is good advice indeed: make sure your Caml type declaration matches the data representation that your Caml/C stub implements... > /* Package up the result as a tuple. */ > v_response = caml_alloc_tuple (3) ; > Store_field (v_response, 0, Val_int (width)) ; > Store_field (v_response, 1, Val_int (height)) ; > Store_field (v_response, 2, caml_copy_string (code)) ; > CAMLreturn (v_response) ; Additionally, do make sure that "v_response" is registered with the GC (declared with one of the CAMLlocal macros). If both conditions are met, your code should be all right. If it still misbehaves, feel free to post a repro case on the bug tracker http://caml.inria.fr/mantis - Xavier Leroy