On Thu, Feb 16, 2012 at 03:15:59AM +0300, Nikolay Sivov wrote:
If I remember correctly, you can even process a va_list only once on some platforms.
We use it that way in couple of places, so it seems to work and I can't find a proper description or part of a standard that says it's not portable.
It definitely isn't portable. The fact that it works sometimes is irrelevant.
See winegcc/wrc for
char* strmake(const char* fmt, ...)
as an example.
That probably means vsnprintf() and similar calls were added as part of C99 as well, so their presence implies working va_copy() is available.
vsnprintf() was added to a lot of system much earlier than va_copy(). Last time I looked I couldn't find a va_copy() for the Microsoft C compiler we were using at the time. In my case it wasn't a printf, but a function that took a list of pointers followed by a NULL - so I copied them into an on-stack array.
David