Advanced C Tips and Techniques Code
Brought to you by:
guigasurf
File | Date | Author | Commit |
---|---|---|---|
README.txt | 2014-03-08 |
![]() |
[b654b8] Explain the difference between function styles,... |
Advanced C Tips and Techniques The book was published on 1988, before the ANSI 9899:1989 (C89) standard. Then, it uses old-style functions instead of the new-style introduced by ANSI. --------------------------------------------------------------------------- A.8.6.3 Function Declarators --------------------------------------------------------------------------- In a new-style function declaration T D where D has the form: D1 ( parameter-type-list ) 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. In an old-style function declaration T D where D has the form: D1 ( identifier-list(opt) ) In the old-style declarator, the identifier list must be absent unless the declarator is used in the head of a function definition. No information about the types of the parameters is supplied by the declaration. --------------------------------------------------------------------------- A.10.1 Function Definitions --------------------------------------------------------------------------- Function definitions have the form: function-definition: declaration-specifiers(opt) declarator declaration-list(opt) compound-statement declarator: pointer(opt) direct-declarator direct-declarator: direct-declarator ( parameter-type-list ) direct-declarator ( identifier-list(opt) ) In the first form of direct-declarator, the function-definition is a new-style function, and its parameters, together with their types, are declared in its parameter-type-list; the declaration-list following the function's declarator must be absent. In the second form, the function-definition is old-style: the identifier-list names the parameters, while the declaration-list attributes types to them. If no declaration is given for a parameter, its type is taken to be int. The new-style function definition is: int max(int a, int b, int c) { } The corresponding old-style definition would be: int max(a, b, c) int a, b, c; { }