set of macros allows portable procedures that accept variable argument lists
to be written. Routines that have variable argument lists but do not use
the varargs() macros are inherently non-portable, as different
machines use different argument-passing conventions. Routines that accept
a variable argument list can use these macros to traverse the list.
va_list is the type defined for the variable used
to traverse the list of arguments.
va_start() is called to initialize pvar to the beginning of the variable argument list. va_start() must be invoked before any access to the unnamed arguments. The
parameter name is the identifier of the rightmost
parameter in the variable parameter list in the function definition (the one
just before the ", ...").
If this parameter is declared with the register storage
class or with a function or array type, or with a type that is not compatible
with the type that results after application of the default argument promotions,
the behavior is undefined.
va_arg() expands to an expression that has the type
and value of the next argument in the call. The parameter pvar must be initialized by va_start(). Each invocation
of va_arg() modifies pvar so that
the values of successive arguments are returned in turn. The parameter type is the type name of the next argument to be returned. The
type name must be specified in such a way that the type of pointer to an object
that has the specified type can be obtained by postfixing a *
to type. If there is no actual next argument, or iftype is not compatible with the type of the actual next argument
(as promoted according to the default argument promotions), the behavior is
The va_copy() macro saves the state represented by
the va_list src in the va_list dest. The va_list
passed as dest should not be initialized by a previous
call to va_start() It then must be passed to va_end() before being reused as a parameter to va_start() or as the dest parameter of a subsequent
call to va_copy(). The behavior is undefined if any of
these restrictions are not met.
The va_end() macro is used to clean up. It invalidates pvar for use (unless va_start() is invoked
Multiple traversals, each bracketed by a call to va_start() and va_end(), are possible.