The function declarator includes the list of parameters that can be passed to the function when it is called by another function, or by itself.
Function parameter declaration syntax .-,-------------. V | >>-(----+-----------+-+--+--------+--)------------------------->< '-parameter-' '-,--...-'
parameter >>-+----------+--type_specifier--+------------+---------------->< '-register-' '-declarator-'
int f()
{
...
}
indicates that function f takes no arguments.
However, int f();
simply indicates that the number and type of parameters
is not known. To explicitly indicate that a function does not take
any arguments, you can replace the argument list with
the keyword void.int f(void);
int f(int, ...);
At least one parameter declaration, as well as a comma before the ellipsis, are both required in C.
In a function declaration, or prototype, the type of each parameter must be specified. In the function definition, if the type of a parameter is not specified, it is assumed to be int.
struct X { int i; };
void print(struct X x);
void print(struct X { int i; } x); // legal
int func(int,long);
Except in certain contexts, an unsubscripted array name (for example, region instead of region[4]) represents a pointer whose value is the address of the first element of the array, provided that the array has previously been declared. An array type in the parameter list of a function is also converted to the corresponding pointer type. Information about the size of the argument array is lost when the array is accessed from within the function body.
To preserve this information, which is useful for optimization, you may declare the index of the argument array using the static keyword. The constant expression specifies the minimum pointer size that can be used as an assumption for optimizations. This particular usage of the static keyword is highly prescribed. The keyword may only appear in the outermost array type derivation and only in function parameter declarations. If the caller of the function does not abide by these restrictions, the behavior is undefined.
void foo(int arr [static 10]); /* arr points to the first of at least
10 ints */
void foo(int arr [const 10]); /* arr is a const pointer */
void foo(int arr [static const i]); /* arr points to at least i ints;
i is computed at run time. */
void foo(int arr [const static i]); /* alternate syntax to previous example */
void foo(int arr [const]); /* const pointer to int */