From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p783mFJx010763 for ; Mon, 8 Aug 2011 05:48:15 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AoYEAFVbP07RVdIpimdsb2JhbABCmC+OfwgUAQEBCgkNBxIGIYFAAQEBAQIBEgIsARseAwELBgULOyIBEQEFARwZIodLnh0KjDGCVYNyO4htAgMGhkAEh1yLJog2hBo8g3o X-IronPort-AV: E=Sophos;i="4.67,335,1309730400"; d="scan'208";a="104913277" Received: from mail-pz0-f41.google.com ([209.85.210.41]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 08 Aug 2011 05:48:09 +0200 Received: by pzk4 with SMTP id 4so2360476pzk.14 for ; Sun, 07 Aug 2011 20:48:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=UmljUScWxZyGV/D2wByBUBW3wSm3GjTHIEIjsJXHA8E=; b=pJ/FigL4p9WYHQ8gQwNAILpKx6HBhqN/TOgccqGbEm0tgiw7YNJGccf3DYcAGmL0JC cOXZxH5jBTChdArbPIfxb0qj5a4aJWNUekczIKFs6JA9axIwtDP7So4to4MQBZaIOZ7p 7AMebuNKg4O8BF6mjdPo0+3CxwhMcbG59jvtQ= MIME-Version: 1.0 Received: by 10.142.239.2 with SMTP id m2mr5045094wfh.169.1312775288068; Sun, 07 Aug 2011 20:48:08 -0700 (PDT) Received: by 10.68.43.66 with HTTP; Sun, 7 Aug 2011 20:48:08 -0700 (PDT) In-Reply-To: <20110808131504.d9137220d4b4401cc3450e5a@mega-nerd.com> References: <20110808131504.d9137220d4b4401cc3450e5a@mega-nerd.com> Date: Sun, 7 Aug 2011 22:48:08 -0500 Message-ID: From: Romain Beauxis To: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p783mFJx010763 Subject: Re: [Caml-list] Val_int vs caml_copy_nativeint 2011/8/7 Erik de Castro Lopo : > Hi all, Hi, > I'm writing a C stub function to allow the calling of a C library > function from ocaml. The return from the stub is a tuple and I'm > doing this: > >    /* 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) ; > > The above works now, but didn't work when I was using > caml_copy_nativeint() instead of Val_int() and I'd like to know > why. I found it especially confusing because caml_copy_string() > worked and was obvioulsy the right thing to do. Reading very briefly the headers. is seems to me that intnat = value = long. Could it be that on the arch you're using sizeof(int) < sizeof(long) ? Romain