Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA
Path: utzoo!watmath!clyde!cbosgd!ihnp4!mhuxn!mhuxj!mhuxr!ulysses!allegra!mit-eddie!godot!harvard!seismo!brl-tgr!tgr!lcc.barry@UCLA-LOCUS.ARPA
From: Barry Gold 
Newsgroups: net.lang.c
Subject: Re: Lattice/UNIX incompatibility
Message-ID: <6845@brl-tgr.ARPA>
Date: Sun, 30-Dec-84 08:33:04 EST
Article-I.D.: brl-tgr.6845
Posted: Sun Dec 30 08:33:04 1984
Date-Received: Mon, 31-Dec-84 03:45:21 EST
Sender: news@brl-tgr.ARPA
Organization: Ballistic Research Lab
Lines: 29

>>	3. Every declaration of an external variable but
>>	   one must say 'extern'.
>
>...#3 is often necessary in non-Unix systems because 
>the linker insists that an occurrence of an external variable 
>is either (a) a reference to something declared elsewhere, or (b) a
>(unique) declaration, and you *must* specify which.  So you cannot just
>treat all occurrences as equivalent, the way the Unix setup does; one
>of them (or all but one of them) must be specially marked.

For any linker that supports FORTRAN, this restriction shows a lack of
imagination on the part of the c compiler writers.  Don't get me started
on this; it's a favorite flame.

To get the unix multiple declaration effect, you need only make the
declarations look like labelled COMMON to the linker.  This reserves space,
with all the areas overlapping and the *largest* determining the amount of
space allocated by the linker.

If you want to initialize such a variable, the (unique) occurrence with an
initializer should look like an ordinary data section (BLOCK DATA) to the
linker.  It *IS* true that at most one of the occurrences of an external
variable may have a initializer.  The other restriction shows stupidity
on the part of the compiler writer or a brain-damaged linker that doesn't
even support ANSI FORTRAN.

barry gold
lcc!barry@ucla-cs.ARPA
ucbvax!ucla-cs!lcc!barry