<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39328 >
On 4/11/07, Jason Short <[EMAIL PROTECTED]> wrote: > <URL: http://bugs.freeciv.org/Ticket/Display.html?id=39328 > > > I don't get it. The args parameter is being modified inside the vsnprintf > function? I had always Yes, the args list is being traversed by 'vsnprintf'. Internally, it likely uses 'va_arg'. > thought it was the other way around - va_start could only be called once per > function but once > called the vargs list was safe to be passed around as needed. No. 'va_start' can be called as many times as you like, but it is probably a good idea to call 'va_end' before calling it again. > Can you come up with some definitive documentation on this? Try reading the man pages to understand how these functions work. Some relevant quotes (my emphasis added) regarding the glibc implementation are as follows: "The include file <stdarg.h> declares a type va_list and defines three macros for *stepping through a list* of arguments whose number and types are not known to the called function." "If there is *no next argument*, or if type is not compatible with the type of the actual next argument (as promoted according to the default argument promotions), *random errors will occur*." "Each invocation of va_start() must be matched by a corresponding invocation of va_end() in the same function. After the call va_end(ap) the variable ap is undefined. *Multiple transversals* of the list, each bracketed by va_start() and va_end() *are possible*. va_end() may be a macro or a function." I am using the GNU implementation of the C library (on an amd64 platform, as I already stated previously). To be more precise, ldconfig reports: libc.so.6 (libc6,x86-64, OS ABI: Linux 2.6.9) => /lib/libc.so.6 /lib/libc.so.6 is a symlink to libc-2.5.so, which means I am using Glibc 2.5. _______________________________________________ Freeciv-dev mailing list [email protected] https://mail.gna.org/listinfo/freeciv-dev
