English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Binding C libraries which use variable arguments (stdarg.h)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-11-01 (12:12)
From: Adrien <camaradetux@g...>
Subject: Re: [Caml-list] Binding C libraries which use variable arguments (stdarg.h)
On 01/11/2009, Florian Weimer <fw@deneb.enyo.de> 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: ‘float’ is promoted to ‘double’ when passed through ‘...’
> a.c:16: note: (so you should pass ‘double’ not ‘float’ to ‘va_arg’)
> 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