Appendix A - Reference Manual

Include(^TCPL/A\..*,,titlesonly)

0.0.1. A.8.6.3 Function Declarators

In a new-style function declaration T D where D has the form

and the type of the identifier in the declaration T D1 is type-modifier T, the type of the identifier of D is type-modifier function with arguments parameter-type-list returning T.

The syntax of the parameters is

In the new-style declaration, the parameter list specifies the types of the parameters. As a special case, the declarator for a new-style function with no parameters has a parameter list consisting soley of the keyword void. If the parameter list ends with an ellipsis , ..., then the function may accept more arguments than the number of parameters explicitly described, see Par.A.7.3.2.

The types of parameters that are arrays or functions are altered to pointers, in accordance with the rules for parameter conversions; see Par.A.10.1. The only storage class specifier permitted in a parameter's declaration is register, and this specifier is ignored unless the function declarator heads a function definition. Similarly, if the declarators in the parameter declarations contain identifiers and the function declarator does not head a function definition, the identifiers go out of scope immediately. Abstract declarators, which do not mention the identifiers, are discussed in Par.A.8.8.

In an old-style function declaration T D where D has the form

and the type of the identifier in the declaration T D1 is type-modifier T, the type of the identifier of D is type-modifier function of unspecified arguments returning T. The parameters (if present) have the form

In the old-style declarator, the identifier list must be absent unless the declarator is used in the head of a function definition (Par.A.10.1). No information about the types of the parameters is supplied by the declaration.

For example, the declaration

declares a function f returning an integer, a function fpi returning a pointer to an integer, and a pointer pfi to a function returning an integer. In none of these are the parameter types specified; they are old-style.

In the new-style declaration

strcpy is a function returning int, with two arguments, the first a character pointer, and the second a pointer to constant characters. The parameter names are effectively comments. The second function rand takes no arguments and returns int.

ch3n2k.com | Copyright (c) 2004-2020 czk.