4.2 extern a DISASTER (Flame)

Jim Kempf kempf at hplabsc.UUCP
Sun Jul 14 08:04:23 AEST 1985


I find the 4.2 C compiler's treatment of extern a total and
complete DISASTER. I have so far been completely unsuccessful
at using extern, though with the 4.1 compiler (which was more
or less K & R standard), there was no trouble. I have traced
loading, and find that, if I specify no initializations for
the variables, the compiler generates TWO seperate common
blocks for the declarations in two seperate files, and the
linker refuses to resolve the two as a reference to the
same variable. If I specify initialization, the compiler
generates an external declaration all right, but no matter
what I do, I can't avoid getting an undefined external
reference from the linker. If I put the extern keyword
before the declaration, if the declaration is at the
top level or in the variable declarations for the block
in which I intend to use the variable-it makes no difference.
The linker tells me that the reference is to an undefined
extern.

Listen: I know extern variables are an undesirable feature
from the software engineering viewpoint, but sometimes they
are handy and, in face, make code easier to understand or
reduce the amount of code one must write. I certainly don't
want some anonomyous compiler writer making it impossible
for me to use them!
		jim kempf	kempf at hplabs

PS: The explaination of extern for the 4.2 compiler on pg.
82 of Harbison & Steele is WRONG, or, if not wrong, then
just incomplete enough to be useless.



More information about the Comp.lang.c mailing list