1581 A function declarator shall not specify a return type that is a function type or an array type.
1582
The only storage-class specifier that shall occur in a parameter
declaration is
1583 An identifier list in a function declarator that is not part of a definition of that function shall be empty.
1584 After adjustment, the parameters in a parameter type list in a function declarator that is part of a definition of that function shall not have incomplete type.
1585
If, in the declaration
D ( parameter-type-list )
or
D ( identifier-listopt )
and the type specified for ident in the declaration
1586 A parameter type list specifies the types of, and may declare identifiers for, the parameters of the function.
1587
A declaration of a parameter as array of
type shall be adjusted to qualified
pointer to type, where the type qualifiers (if any)
are those specified within the
1588
If the keyword
1589 A declaration of a parameter as function returning type shall be adjusted to pointer to function returning type, as in 6.3.2.1.
1590
If the list terminates with an ellipsis
1591
The special case of an unnamed parameter of type
1592
1593
If the function declarator is not part of a definition of that
function, parameters may have incomplete type and may use the
1594 The storage-class specifier in the declaration specifiers for a parameter declaration, if present, is ignored unless the declared parameter is one of the members of the parameter type list for a function definition.
1595 An identifier list declares only the identifiers of the parameters of the function.
1596 An empty list in a function declarator that is part of a definition of that function specifies that the function has no parameters.
1597 The empty list in a function declarator that is not part of a definition of that function specifies that no information about the number or types of the parameters is supplied.124)
1598
123) The macros defined in the
1599 124) See future language directions (6.11.6).
1600 For two function types to be compatible, both shall specify compatible return types.125)
1601 Moreover, the parameter type lists, if both are present, shall agree in the number of parameters and in use of the ellipsis terminator;
1602 corresponding parameters shall have compatible types.
1603 If one type has a parameter type list and the other type is specified by a function declarator that is not part of a function definition and that contains an empty identifier list, the parameter list shall not have an ellipsis terminator and the type of each parameter shall be compatible with the type that results from the application of the default argument promotions.
1604 If one type has a parameter type list and the other type is specified by a function definition that contains a (possibly empty) identifier list, both shall agree in the number of parameters, and the type of each prototype parameter shall be compatible with the type that results from the application of the default argument promotions to the type of the corresponding identifier.
1605 (In the determination of type compatibility and of a composite type, each parameter declared with function or array type is taken as having the adjusted type and each parameter declared with qualified type is taken as having the unqualified version of its declared type.)
1606 EXAMPLE 1 The declaration
int f(void), *fip(), (*pfi)();
declares a function
If the declaration occurs outside of any function, the identifiers
have file scope and external linkage. If the declaration occurs
inside a function, the identifiers of the functions
1607 EXAMPLE 2 The declaration
int (*apfi[3])(int *x, int *y);
declares an array
1608 EXAMPLE 3 The declaration
int (*fpfi(int (*)(long), int))(int, ...);
declares a function
1609 125) If both function types are old style, parameter types are not compared.
1610 EXAMPLE 4 The following prototype has a variably modified parameter.
void addscalar(int n, int m,
double a[n][n*m+300], double x);
int main()
{
double b[4][308];
addscalar(4, 2, b, 2.17);
return 0;
}
void addscalar(int n, int m,
double a[n][n*m+300], double x)
{
for (int i = 0; i < n; i++)
for (int j = 0, k = n*m+300; j < k; j++)
// a is a pointer to a VLA with n*m+300 elements
a[i][j] += x;
}
1611 EXAMPLE 5 The following are all compatible function prototype declarators.
double maximum(int n, int m, double a[n][m]);
double maximum(int n, int m, double a[*][*]);
double maximum(int n, int m, double a[ ][*]);
double maximum(int n, int m, double a[ ][m]);
as are:
void f(double (* restrict a)[5]);
void f(double a[restrict][5]);
void f(double a[restrict 3][5]);
void f(double a[restrict static 3][5]);
(Note that the last declaration also specifies that the argument
corresponding to
1612 Forward references: function definitions (6.9.1), type names (6.7.6).
Next
Created at: 2005-06-29 02:19:02
The text from WG14/N1124 is copyright © ISO