Go to the first, previous, next, last section, table of contents.


Argument Access Macros

Here are descriptions of the macros used to retrieve variable arguments. These macros are defined in the header file `stdarg.h'.

Data Type: va_list
The type va_list is used for argument pointer variables.

Macro: void va_start (va_list ap, last-required)
This macro initializes the argument pointer variable ap to point to the first of the optional arguments of the current function; last-required must be the last required argument to the function.

See section Old-Style Variadic Functions, for an alternate definition of va_start found in the header file `varargs.h'.

Macro: type va_arg (va_list ap, type)
The va_arg macro returns the value of the next optional argument, and modifies the value of ap to point to the subsequent argument. Thus, successive uses of va_arg return successive optional arguments.

The type of the value returned by va_arg is type as specified in the call. type must be a self-promoting type (not char or short int or float) that matches the type of the actual argument.

Macro: void va_end (va_list ap)
This ends the use of ap. After a va_end call, further va_arg calls with the same ap may not work. You should invoke va_end before returning from the function in which va_start was invoked with the same ap argument.

In the GNU C library, va_end does nothing, and you need not ever use it except for reasons of portability.


Go to the first, previous, next, last section, table of contents.