... (Ellipsis)
 
Used in place of procedure parameter to pass a variable number of arguments, or as the upper bound in an array declaration to denote that the number of elements will be determined by the initializer.

Syntax

Declare { Sub | Function } proc_name cdecl ( param As datatype, ... )

Dim array_symbol ([lbound To] ...) [As datatype] => { expression_list }

#define identifier( [ parameters, ] variadic_parameter... ) macro_text


Description

The ellipsis (three dots, ...) is used in procedure declarations and definitions to indicate a variable argument list. A first argument must always be specified and the function must be called with the C calling convention cdecl. In the procedure body, va_first, va_arg and va_next are used to handle the variable arguments.

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.

Using an ellipsis in a #define or #macro declaration allows to create a variadic macro, see #define.

Example

Declare Function FOO cdecl (X As Integer, ...) As Integer


Example

Dim As Integer myarray(0 To ...) = {0, 1, 2, 3}
Print LBound(myarray), UBound(myarray)   '' 0, 3


Differences from QB

  • New to FreeBASIC

See also