From: Ian Lance Taylor <iant@google.com>
To: Constantine Kousoulos <wuwei@freemail.gr>
Cc: gcc-help@gcc.gnu.org
Subject: Re: varargs
Date: Thu, 28 Jun 2007 05:25:00 -0000 [thread overview]
Message-ID: <m36458wvn9.fsf@localhost.localdomain> (raw)
In-Reply-To: <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
next prev parent reply other threads:[~2007-06-28 4:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-26 4:41 varargs Constantine Kousoulos
2007-06-28 5:25 ` Ian Lance Taylor [this message]
-- strict thread matches above, loose matches on Subject: below --
2004-04-15 19:35 varargs Phil Prentice
2004-04-15 20:56 ` varargs llewelly
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m36458wvn9.fsf@localhost.localdomain \
--to=iant@google.com \
--cc=gcc-help@gcc.gnu.org \
--cc=wuwei@freemail.gr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).