The ellipsis (three dots,
...) is used in procedure declarations and definitions to indicate a variable argument list.
A first argument (at least) must always be specified and the procedure must be called with the C calling convention
cdecl.
In the procedure body,
Cva_List data type, and
Cva_Arg macro can be used to expand the ellipsis parameter (
...) to obtain the values of the arguments passed to the variadic procedure. The argument list, once initialized with
Cva_Start or copied with
Cva_Copy, can be passed to another procedure taking a
Cva_List parameter.
On some targets, for backwards compatibility,
va_first,
va_arg and
va_next can still be used to handle the variable arguments.
Only numeric types and pointers are supported as variable arguments (all bytes and shorts passed on variable arguments are implicitly converted to integers, all singles passed on variable arguments are implicitly converted to doubles).
Strings can be passed, in which case a
ZString Ptr to the string data is taken.
A variadic procedure name can never be overloaded.
Using an ellipsis behind the last parameter in a
#define or
#macro declaration allows creation of a variadic macro. This means it is possible to pass any number of arguments to the
variadic_parameter, which can be used in the
body as if it was a normal macro parameter. The
variadic_parameter will expand to the full list of arguments passed to it, including commas, and can also be completely empty.
Note: To distinguish between the different arguments passed by
variadic_parameter, you can first convert
variadic_parameter to a string using the
Operator # (Preprocessor Stringize), then differentiate in this string (
#variadic_parameter) each passed argument by locating the separators (usually a comma).
Using an ellipsis in place of the upper bound in an array declaration causes the upper bound to be set according to the data that appears in the
expression_list. When the ellipsis is used in this manner, an initializer must appear, and cannot be
Any.