Page t031, go to NEXT,
PREVIOUS, INDEX
Declarations and Definitions
Programs must be broken up into units which are compiled separately
- standard functions are compiled and put in libraries
- program code is compiled and linked to libraries
- other program code is compiled and linked to libraries
Functions and other externals must be declared before their use
extern double sqrt (double);
double x, y, z, r;
/* initialization, etc. */
r = sqrt (x*x + y*y + z*z);
- sqrt (double) and
sqrt (double x) are equivalent in the declaration
statement
What would happen if the declaration we used did not correspond to
the function definition in the library?
To ensure consistency, we must force the library function and
the function we use in a program to share the same declaration
C Course, 21-jan-1997,
Peter Klok,
pfk@hef.kun.nl