stdarg.h is a header in the C standard library of the C programming language that allows functions to accept an indefinite number of arguments.
[1] It provides facilities for stepping through a list of function arguments of unknown number and type.
There is no defined method for counting or classifying the unnamed arguments passed to the variadic function.
Common conventions include: As the size of the unnamed argument list is generally unknown, the calling conventions employed by most compilers do not permit determining the size of the unnamed argument block pointed at by va_list inside the receiving function.
For example, vfprintf() is an alternate version of fprintf() expecting a va_list instead of the actual unnamed argument list.
Some C implementations provide C extensions that allow the compiler to check for the proper use of format strings and sentinels.
For example, the declaration: causes the compiler to check the arguments in calls to my_printf for consistency with the printf style format string argument my_format[4] This program should get the following output: Outdated versions of POSIX defined the legacy header varargs.h, which dates from before the standardization of C and provides functionality similar to stdarg.h.
The file, as defined in the second version of the Single UNIX Specification, simply contains all of the functionality of C89 stdarg.h, with the exceptions that: The interface is also different.