Redeclaration of Variables extern/static

Doug Gwyn gwyn at smoke.brl.mil
Wed Apr 10 14:08:54 AEST 1991


In article <1991Apr9.055250.24257 at world.std.com> geoff at world.std.com (Geoff Collyer) writes:
>>>C News, amongst other things, has declarations of ``extern int foo;'' in
>>>either a header or towards the top of a file, and later has ``static int
>>>foo;''.
>this is an ugly case.  Some Classic compilers (including the original one,
>if memory serves) can't cope with forward static declarations at all.

I've never seen a UNIX C compiler that had a problem with multiple
declarations of the same object with static linkage, so long as all
declarations of the object included the "static" storage specifier.
It's the mixing of "extern" and "static" that causes the trouble,
but then there is no reason to do that in the first place.



More information about the Comp.lang.c mailing list