This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Ada in gcc-3.4.3 on x86_64
- From: Florian Weimer <fw at deneb dot enyo dot de>
- To: Robert Dewar <dewar at adacore dot com>
- Cc: Dean Kolosiek <kolosiekweb04 at qwest dot net>, gcc at gcc dot gnu dot org, Gary Dismukes <dismukes at adacore dot com>, Ed Schonberg <schonberg at adacore dot com>
- Date: Wed, 05 Jan 2005 17:26:42 +0100
- Subject: Re: Ada in gcc-3.4.3 on x86_64
- References: <6.1.2.0.0.20050105011154.03606230@pop.phnx.qwest.net><41DBF735.30204@adacore.com>
* Robert Dewar:
> Here would be my specification of this feature
>
> A new convention identifier C_Varargs is introduced. This convention
> may only be used in the context of a pragma Import. It indicates that
> the function being imported is a varargs function in C, so that the
> appropriate calling sequence must be used. On the Ada side, there is
> no direct facility for allowing a variable number of arguments. However
> it is possible to use multiple imports for different arguments. For
> example, we might have for printf:
>
> procedure printf_int (S : Interfaces.char_array, V : interfaces.int);
> pragma Import (C_Varargs, printf_int, External_Name => "printf");
>
> Note: on some architectures, the calling sequences for an n-adic function
> and a variadic function with n arguments are the same. On such architectures
> the convention C_Varargs will be equivalent to the convention C. However
> there are architectures where the calling sequences are different, and that
> is why in general two convention identifiers are required.
In the pragma, you'd have to specify the number of non-variadic
arguments. I'm pretty sure that this number may also affect the
calling convention. This seems to follow from 6.7.5.3(15) (in the
C Standard).