* varargs
@ 2004-04-15 19:35 Phil Prentice
2004-04-15 20:56 ` varargs llewelly
0 siblings, 1 reply; 4+ messages in thread
From: Phil Prentice @ 2004-04-15 19:35 UTC (permalink / raw)
To: gcc-help
Hi
We are currently porting software using the gnu compiler (3.3.3). Its
working very well so far, but we have a problem over varargs.
There are dozens of files which use varargs (not stdarg). In time we will
move these files over to use stdarg, however we have the added problem of
there having to be at least one parameter being declared for stdarg to
compile and work.
1) Is there anyway that we can cheat here or do we have to go through all
the function calls and add a dummy parameter etc to enable us to use
stdarg's?? Many of these functions accept 0 or more tag parameters. How do
we cope with no parameters?
2) Same question really, but a considerably amount of software exists
which interfaces to our varargs software which would be nia on impossible to
change. Again in this case are we stuck to having to use an older version of
the compiler which supports varargs or again can we cheat somehow?
3) What is the latest version of the compiler that still supports varargs?
It would be nice to use stdarg but without the worry of changing the
calling software? Is there any way around the problem of zero parameters?
Thanks again for all your help
Phil
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: varargs
2004-04-15 19:35 varargs Phil Prentice
@ 2004-04-15 20:56 ` llewelly
0 siblings, 0 replies; 4+ messages in thread
From: llewelly @ 2004-04-15 20:56 UTC (permalink / raw)
To: Phil Prentice; +Cc: gcc-help
Phil Prentice <philp.cheer@btinternet.com> writes:
> Hi
>
> We are currently porting software using the gnu compiler (3.3.3). Its
> working very well so far, but we have a problem over varargs.
Sorry, but I think gcc support for varargs and other pre-C89
constructs is a thing of the past. gcc 3.2 was the last to
support -traditional, and I can't find the docs for when varargs
support was dropped. I suppose you could try 3.2.3 as an interm
solution.
>
> There are dozens of files which use varargs (not stdarg). In time we will
> move these files over to use stdarg, however we have the added problem of
> there having to be at least one parameter being declared for stdarg to
> compile and work.
>
> 1) Is there anyway that we can cheat here or do we have to go through all
> the function calls and add a dummy parameter etc to enable us to use
> stdarg's?? Many of these functions accept 0 or more tag parameters. How do
> we cope with no parameters?
>
> 2) Same question really, but a considerably amount of software exists
> which interfaces to our varargs software which would be nia on impossible to
> change. Again in this case are we stuck to having to use an older version of
> the compiler which supports varargs or again can we cheat somehow?
[snip]
I can't think of any off the top of my head, but I would be tempted to
experiment with some well-thought-out macro-hackery.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: varargs
2007-06-26 4:41 varargs Constantine Kousoulos
@ 2007-06-28 5:25 ` Ian Lance Taylor
0 siblings, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2007-06-28 5:25 UTC (permalink / raw)
To: Constantine Kousoulos; +Cc: gcc-help
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* varargs
@ 2007-06-26 4:41 Constantine Kousoulos
2007-06-28 5:25 ` varargs Ian Lance Taylor
0 siblings, 1 reply; 4+ messages in thread
From: Constantine Kousoulos @ 2007-06-26 4:41 UTC (permalink / raw)
To: gcc-help
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?
Thanks,
Constantine
PS I'm using gcc-4.1.3.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-06-28 4:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-15 19:35 varargs Phil Prentice
2004-04-15 20:56 ` varargs llewelly
2007-06-26 4:41 varargs Constantine Kousoulos
2007-06-28 5:25 ` varargs Ian Lance Taylor
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).