Lattice/UNIX incompatibility

Barry Gold lcc.barry at UCLA-LOCUS.ARPA
Sun Dec 30 23:33:04 AEST 1984


>>	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 at ucla-cs.ARPA
ucbvax!ucla-cs!lcc!barry



More information about the Comp.lang.c mailing list