From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 42565BBAF for ; Sun, 1 Nov 2009 13:12:36 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtUBAN4J7UrRVdrVkGdsb2JhbACRaYIshn4/AQEBAQkJDAcTA64ygTmFDIhoAQMDBYQ0BIFi X-IronPort-AV: E=Sophos;i="4.44,662,1249250400"; d="scan'208";a="49593042" Received: from mail-bw0-f213.google.com ([209.85.218.213]) by mail4-smtp-sop.national.inria.fr with ESMTP; 01 Nov 2009 13:12:35 +0100 Received: by bwz5 with SMTP id 5so5341830bwz.3 for ; Sun, 01 Nov 2009 04:12:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=QLEQYX1D5mDG+A47qVC4gLAa5701Ak4Od8TRMeVBZOw=; b=Cpi5e5fvX0CSBd4Atg+bUJlR6yj0mBYJ15/1ZxdVFQI507WeVqPL1hEJoixqPGIWJG Oi4yIEbVXzWSbfv/NmL9JvZkdIrbh5DLkspNUncaO7qUTzHwlxZPTRQRRskav8H8GtDl vMcfGghhnn+4svx6i5GMYmsUaVE7prk6kiY4M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=u3t0thuVXud+0s3tmfirgTZCjXSm8K9wvfkghwAMek3TndirbcvyYp/EKxoqco80uT 2iNzFQ8zX72qNH5QNqyWPObwI72YykHpS8JmFteNY5iFB/4+Ixz9jVrJYGRLdZx0SOoB osOy4DhYHAKDyI8uqnwmvpnw5kIKaG9ScUaNs= MIME-Version: 1.0 Received: by 10.103.48.17 with SMTP id a17mr1540698muk.82.1257077553945; Sun, 01 Nov 2009 04:12:33 -0800 (PST) In-Reply-To: <87ljiqmrjy.fsf@mid.deneb.enyo.de> References: <666572260910281507q74cb1c1at157c9e3c86070c69@mail.gmail.com> <4AE8C987.8020100@starynkevitch.net> <666572260910291418p585b0aa9laadc14f6589c9772@mail.gmail.com> <4AEAB347.3060008@inria.fr> <666572260911010131x1b3c778bgc1c87879ca96a62d@mail.gmail.com> <87ljiqmrjy.fsf@mid.deneb.enyo.de> Date: Sun, 1 Nov 2009 13:12:33 +0100 Message-ID: <666572260911010412n3f60bb21pc6e1d3bb70279f58@mail.gmail.com> Subject: Re: [Caml-list] Binding C libraries which use variable arguments (stdarg.h) From: Adrien To: Florian Weimer Cc: Caml Mailing List Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; userland:01 debian's:01 varargs:01 wrote:01 caml-list:01 functions:01 conventions:02 binding:02 florian:03 apis:03 arg:03 float:03 float:03 passing:05 problem:05 On 01/11/2009, Florian Weimer wrote: > * Adrien: > >> It turned out it worked on linux x86_32, linux x86_64, netbsd sparc64 >> with 32-bit userland, debian's kfreebsd amd64 and ppc32. There's >> windows which I haven't checked yet though. > > x86_64 has different calling conventions for varargs and non-varargs > functions. If it works for you, it's only by accident (e.g. because > you aren't passing floating-point arguments). > I tried a few things with "double" at first since I'm on x86_64 and got no warning and no problem whatsoever. The situation was a bit different with "float" however : > a.c:16: warning: =91float=92 is promoted to =91double=92 when passed thro= ugh =91...=92 > a.c:16: note: (so you should pass =91double=92 not =91float=92 to =91va_a= rg=92) > a.c:16: note: if this code is reached, the program will abort Running the program yields a nice: "illegal hardware instruction ./a.out".= :) The problem is the same on x86_32 however, and APIs are probably correct with regard to that. I'll see if I can add checks in ocaml-gir nonetheless. Thanks. --- Adrien Nader