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:

> Florian Weimer wrote:
>
>>>    procedure printf_int (S : Interfaces.char_array, V : interfaces.int);
>>>    pragma Import (C_Varargs, printf_int, External_Name => "printf");
>
>> 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).
>
> No, you don't need to specify this, since the pragma is a pragma
> Import for a specific variant, e.g. in my example above, you know
> that you are talking about the two argument case.

No, There are two possible variadic declarations for printf in this
case:

  void printf (char *, ...);

and 

  void printf (char *, int, ...);

(Yeah, I know, real printf has return type int. 8-)

If I interpret the C standard correctly, these two do not necessarily
share the same calling convention.

You can fix the AMD64 case even though you don't know the place of the
ellipsis, but you can't solve the general case!

> Remember, I am NOT proposing adding a pragma, but rather adding a
> convention for use by pragma Import.

If you don't want to add a new pragma, you have to encoded the number
of arguments in the string passed as External_Name, which is ugly.


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