4.2::SYSV compatability problem

Guy Harris guy at rlgvax.UUCP
Wed Jan 30 04:29:10 AEST 1985


Ah yes, the old "multiple extern" problem.

The C language reference says that only one definition of an external
variable (i.e. something without "extern" in front of it) is allowed;
all other declarations must be references using "extern".  This is because
the UNIX linker is one of the few linkers (the only one?) which uses the
FORTRAN common-block model for external declarations, where if the symbol
is defined several times it takes the biggest of the declarations and
uses that.  Most other linkers choke if given more than one declaration.

In practice, since the UNIX linker doesn't choke on multiple declarations
(prior to System V), UNIX code was written to assume it was OK to declare
something more than once.  The System V linker was changed to choke on
this - I guess to "enforce" the same restriction that other linkers have,
in order to detect code that couldn't be moved to other OSes.  The System
V Release 2 linker, on the VAX at least, changed this back (in response
to a chorus of howls from users, I suspect) but provided an option to
support the old S5R1 behavior.  I suspect AT&T may not have put the latest
linker into your 3B; complain to them (or change your code; once that's
done, it makes it more likely that the code will work on other systems
which don't use the common-block model for externals).

And no, Berkeley didn't fix anything.  Bell, arguably, broke something
in S5R1; given that they changed it back in S5R2, they may agree.  (Lots
of things that you might think are "Berkeley vs. S5" or "Berkeley vs. Bell"
aren't.)

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy



More information about the Comp.unix.wizards mailing list