Guardian C Library Calls Reference Manual
va_arg
3-230 128833—Guardian TNS C Library Calls Reference Manual
Reference to Library Calls
va_arg
The va_arg macro expands to an expression whose value is that of the next argument in
the argument list that contains a variable number of arguments. This expression has the
type you specify in the invocation of va_arg.
ap
is a variable of type va_list that has been initialized by a previous invocation of the
va_start macro.
<type>
is the name of the expected type of the next argument in the argument list that
contains a variable number of arguments. <type> must be a type name such that the
type pointer to <type> can be created by adding * after <type> (as in <type> *).
Return Value
is an expression of type <type> whose value is that of the next argument in the
argument list that contains a variable number of arguments.
Usage Guidelines
•
Following an invocation of va_start, the first invocation of va_arg expands to the
value of the first argument in the argument list, the second invocation of va_arg
expands to the value of the second argument in the list, and so on.
•
Once all of the arguments in the argument list have been extracted, subsequent
invocations of va_arg (with the same ap and without an intervening invocation of
va_start) expand to random values.
•
If <type> differs from the actual type (as passed by the caller of the function) of the
next argument in the list, the return value might be incorrect. All subsequent
invocations of va_arg (with the same ap and without an intervening invocation of
va_start) can produce incorrect values as well.
#include <stdargh>
<type> va_arg(va_list ap, <type>);