This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Ada in gcc-3.4.3 on x86_64


* 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).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]