This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Calling va_start multiple times vs __va_copy
- To: gcc at gcc dot gnu dot org
- Subject: Calling va_start multiple times vs __va_copy
- From: Sebastian Ude <ude at handshake dot de>
- Date: Wed, 08 Aug 2001 13:38:05 +0200
- Reply-To: ude at handshake dot de
Is it legitime to parse the optional arguments in a variadic function
multiple times _without_ copying the va_list through (__)va_copy ?
I mean a situation like this one:
void foo( int argno, ... )
{
va_list ap;
va_start(ap, argno);
/* parse arguments through va_arg */
va_end(ap);
va_start(ap, argno);
/* parse arguments again */
va_end(ap);
}
With GCC, that works - but is that against the standards ?
Some documentations recommend to copy the va_list after initializing it
instead of initializing it multiple times:
/* [...] */
va_list ap, ap2;
va_start(ap, argno);
__va_copy(ap2, ap);
/* parse arguments of ap through va_arg */
va_end(ap);
/* parse arguments of ap2 through va_arg */
va_end(ap2);
*/ [...] */
Well, the second one seems more logical - but is the first one
standard-confirming ?
Can a va_list be started multiple times through va_start ?
But, __va_copy does not belong to the ISO standard, right ?
And a direct assigment of two va_list variables would be not possible, too
?
So isn't the second example non-standard confirming ?
Thanks for any explanations,
Sebastian Ude