This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: varargs
- From: Ian Lance Taylor <iant at google dot com>
- To: Constantine Kousoulos <wuwei at freemail dot gr>
- Cc: gcc-help at gcc dot gnu dot org
- Date: 27 Jun 2007 21:27:54 -0700
- Subject: Re: varargs
- References: <46803665.2030501@freemail.gr>
Constantine Kousoulos <wuwei@freemail.gr> writes:
> I have a printf() function written in C using va_start, va_arg,
> etc. It works fine on i386. Lately, i needed it on my amd64
> machine. However, although it builds, it does not work.
>
> After reading the x86_64 ABI, i found out that on amd64 each
> function's args are moved to specific registers and not to the stack
> (like on i386).
>
> Do i need to do something extra to use varargs functions on x86_64?
No. Doing a #include of <stdarg.h> should suffice.
Note that on x86_64, unlike i386, int and long have different sizes.
That means that varargs functions have more chances to make mistakes.
If the caller passes a long, you must use va_arg(long), not
va_arg(int).
Ian
- References:
- varargs
- From: Constantine Kousoulos