Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

va_arg - process variable argument list

&pagelevel(4)&pagelevel

Syntax

#include <stdarg.h>

Optional
#include <varargs.h> (End)

type va_arg(va_list ap, type);

Description

The va_arg, va_start and va_end macros allow portable procedures that accept variable
argument lists, as defined in stdarg.h, to be written. They are used to process a list of
arguments which may vary in number and type at each function call.

va_arg returns the data type and value of the next argument in a variable argument list ap,
starting with the first argument. Technically speaking, the macro expands into an
expression of the data type and value of the argument.

The variable argument list to which ap points must be initialized with va_start before the
first call to va_arg. Each invocation of va_arg modifies ap so that the value of the next
argument in turn is returned.

ap is a pointer to the argument list initialized with va_start before va_arg is called for the
first time.

type is a type name matching the type of the current argument. Any C data type, for which
a pointer to an object of the specified type is defined by simply appending an * to type, is
allowed. Array and function types, for example, are invalid.

If there is no next argument or if type does not match the current argument, the behavior is
undefined.

Return val.

Value of the first argument

when va_arg() is called for the first time after va_start. This argument
comes after the last "named" argument parmN in the formal parameter list
(see also va_start()). Subsequent calls return the remaining argument
values in succession.

Notes

Compatibility of argument types is supported by the C runtime system to the extent that
similar types are stored in the same way in the parameter list, i.e.: all unsigned types
(including char) are represented as unsigned int (right-justified in a word), and all other
integer types are represented as int (right-justified in a word). float is represented as
double (right-justified in a doubleword).
The va_end macro must be called before returning from a function whose argument list was
processed with va_arg.

See also

va_start(), va_end(), stdarg.h, varargs.h.