Previous Table of Contents "New C Standard" commentary
1592 A function declarator shall not specify a return type that is a function type or an array type.
1593
The only storage-class specifier that shall occur in a parameter
declaration is
1594 An identifier list in a function declarator that is not part of a definition of that function shall be empty.
1595 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.
1596
If, in the declaration
D ( parameter-type-list )
or
D ( identifier-listopt )
and the type specified for ident in the declaration
1597 A parameter type list specifies the types of, and may declare identifiers for, the parameters of the function.
1598
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
1599
If the keyword
1600 A declaration of a parameter as function returning type shall be adjusted to pointer to function returning type, as in 6.3.2.1.
1601
If the list terminates with an ellipsis
1602
The special case of an unnamed parameter of type
1603
1604
If the function declarator is not part of a definition of that
function, parameters may have incomplete type and may use the
1605 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.
1606 An identifier list declares only the identifiers of the parameters of the function.
1607 An empty list in a function declarator that is part of a definition of that function specifies that the function has no parameters.
1608 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)
1609
123) The macros defined in the
1610 124) See future language directions (6.11.6).
1611 For two function types to be compatible, both shall specify compatible return types.125)
1612 Moreover, the parameter type lists, if both are present, shall agree in the number of parameters and in use of the ellipsis terminator;
1613 corresponding parameters shall have compatible types.
1614 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.
1615 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.
1616 (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.)
1617 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
1618 EXAMPLE 2 The declaration
int (*apfi[3])(int *x, int *y);
declares an array
1619 EXAMPLE 3 The declaration
int (*fpfi(int (*)(long), int))(int, ...);
declares a function
1620 125) If both function types are old style, parameter types are not compared.
1621 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;
}
1622 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
1623 Forward references: function definitions (6.9.1), type names (6.7.6).
Next
Created at: 2008-01-30 02:39:44
The text from WG14/N1256 is copyright © ISO