Jos Horsmeier writes:
>In article <....> Larry Jones writes:
>|In article <....>, David Alan Boles writes:
>|> static void dummy(int, int, int *);
>|> void dummy(int a, int b, int *c) { *c = a + b; }
>|>
>|> Looking at Steele's book, it seems to say that the word static must
>|> be present in both places, but it is not clear on this. [...]
>|
>|It says you have to have static in both places. [...]
>
> No, if the first declaration declares the object to be a static object
> (no external linkage), following declarations (and the definition) can
> omit the `static' keyword. The other way around would result in a
> compiler warning though ...
Jos Horsmeier has started talking about objects now where Larry Jones and David Alan Boles were discussing functions. Unfortunately, function and object linkages are treated differently.
The rules that Larry thought apply to functions apply to objects, while the rules that Jos states for objects apply to functions.
Example:
/* object */ /* function */ int o1; int f1(); /* external linkage */ static int o2; static int f2(); /* internal linkage */ static int o3; static int f3(); /* internal linkage */ static int o1; static int f1(); /* ERROR, both have external linkage */ int o2; /* ERROR, o2 has internal linkage */ int f2(); /* OK, picks up internal linkage */ extern int o3; extern int f3(); /* OK, both pick up internal linkage */
The difference is case (2); where functions do pick up a previous linkage even without "extern", objects don't.
Jutta Degener