One possible use of va_copy is in an implementation of print[f]()
that supports an option to get a specific argument. For example,
print("%2#s %1#s", "second", "first");
prints
first second
For example, one could maintain an array of the first n va_list
items, save them as they are read, and then use the copies when
necessary. The other option is
va_end()
va_start()
while (newcount < count)
va_arg()
which could flood your code.
On Jan 24, 2008, at 5:39 PM, Russ Cox wrote:
i didn't see anything in the definition that would make va_copy
wrong given the plan 9 definition of va_list. is there a particular
case on plan 9 that would be a problem?
it might make sense to *have* va_copy, but since plan 9
programs don't use va_copy, there's no need to provide
an implementation. and honestly, the fewer people who
use va_copy, the better.
but plan 9 does have va_start and va_end. wouldn't make sense
to have va_copy as well?
plan 9 makes no claims of being C99 compliant,
although it happens to have a few of the same extensions.
va_start, va_end, and va_arg are from an earlier standard.
those (in particular va_arg) provide useful functionality.
va_copy does not.
like i said, if you need it, it's easy to put a #define
in your own compatibility headers. if you don't
need it, don't worry about it.
russ