Multiple external definitions

Guy Harris guy at rlgvax.UUCP
Tue Mar 12 10:22:12 AEST 1985


> > All UNIXes prior to System V supported multiple external definitions.
> 
> Our Xenix system, however, doesn't, for all that it was developed from V7
> source.  Lots of programs fail spectacularly on my terminal (including the
> editor I'm using to type this in), because my terminal requires padding
> and almost every termcap-using program we get has "int ospeed;" in it
> (we need "extern short ospeed;", also outlining a certain size dependency...

If your program links without complaint, then your Xenix supports multiple
external definitions.  If it only fails on your terminal, it must have linked
without complaint in order to run on another terminal.  The problem you're
describing is a separate problem; externals in UNIX behave like FORTRAN
common blocks, in that externals have a size, and if you have several
declarations of the same external with different sizes, the biggest one
wins.  If your machine has 32-bit "int"s, and it's big-endian (like a
68000 with 32-bit "int"s), then one declaration as a "short" and one
declaration as an "int" won't work (references to the "short" will pick up
the *upper* 16 bits of the "short", which will be zero, and thus give no
padding).  (If your machine is little-endian, it's *still* wrong, but
symptomless in this particular case.)
-- 
	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy



More information about the Comp.lang.c mailing list