HP C/iX Library Reference Manual (30026-90004)

Chapter 5 383
HP C/iX Library Function Descriptions
va_start
va_start
Initializes a variable to the beginning of an argument list.
Syntax
#include <stdarg.h>
void va_start (va_list
ap
,
parmN
);
Parameters
ap
A pointer to a double, as defined by type va_list in <varargs.h>.
parmN
The identifier of the rightmost parameter in the variable parameter list in
the function definition. This is the identifier just before the horizontal
ellipsis.
Return Values
None.
Description
The va_start macro initializes
ap
(of type va_list) for subsequent use by va_arg and
va_end. It must be invoked before va_arg can be used.
The macros va_start, va_arg, and va_end determine the arguments of a function that
can be called with a variable number of arguments. The variable number of arguments are
indicated by the ellipsis in the function header.
NOTE
The header <varargs.h> also contains this macro. However, <varargs.h> is
not defined by the ANSI C standard.
Examples
The following program uses <stdarg.h>:
#include <stdarg.h>
#include <stdio.h>
enum arglisttype {NO_VAR_LIST, VAR_LIST_PRESENT};
enum argtype {END_OF_LIST, CHAR, DOUB, INT, PINT};
int func (int a1, enum arglisttype a2, ...)
{
va_list ap;
enum argtype ptype;
int i, *p;