4.5. SummaryWith the appropriate declarations, you can have names that are visible throughout the program or limited to a single file or limited to a single function, as appropriate. Here are the combinations of the use of the keywords, the types of declarations and the resulting linkage:
There are a few golden rules for the use of functions that are worth re-stating too.
A declaration of the types of arguments that a function takes is not mandatory, but it is extremely strongly recommended. Functions taking a variable number of arguments can be written portably if you use the methods described in Section 9.9. Functions are the cornerstone of C. Of all the changes to the language, the Standard has had by far its most obvious effect by introducing function prototypes. This change has won widespread approval throughout the user community and should help to produce a substantial improvement in reliability of C programs, as well as opening the possibility of optimization by compilers in areas previously closed to them. The use of call-by-value is sometimes surprising to people who have used languages that prefer a different mechanism, but at least the C approach is the ‘safest’ most of the time. The attempts by the Standard to remove ambiguity in the scope and meaning of declarations are interesting, but frankly have explored an obscure region which rarely caused any difficulties in practice. From the beginner's point of view, it is important to learn thoroughly everything discussed in this chapter, perhaps with the exception of the linkage rules. They can be deferred for a more leisurely inspection at some later time. Footnotes1. Stroustrup B. (1991). The C++ Programming Language 2nd edn. Reading, MA: Addison-Wesley |
The C BookThis book is published as a matter of historical interest. Please read the copyright and disclaimer information. GBdirect Ltd provides up-to-date training and consultancy in C, Embedded C, C++ and a wide range of other subjects based on open standards if you happen to be interested. |
||||||||||||||||||||||||||||||||||||||||||||||
West Yorkshire Office
GBdirect Ltd
Training: 0800 651 0338 Please call between 0900 and 1700 (UK time) on Monday to Friday South East Regional Office
GBdirect Ltd
Training: 0800 651 0338 Please call between 0900 and 1700 (UK time) on Monday to Friday Please note: |
|||||||||||||||||||||||||||||||||||||||||||||||