Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/17/84; site hplabsc.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!allegra!oliveb!hplabsc!kempf
From: kempf@hplabsc.UUCP (Jim Kempf)
Newsgroups: net.lang.c
Subject: 4.2 extern a DISASTER (Flame)
Message-ID: <2643@hplabsc.UUCP>
Date: Sat, 13-Jul-85 18:04:23 EDT
Article-I.D.: hplabsc.2643
Posted: Sat Jul 13 18:04:23 1985
Date-Received: Wed, 17-Jul-85 04:45:28 EDT
Distribution: net
Organization: Hewlett Packard Labs, Palo Alto CA
Lines: 29

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@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.