Re: 2.1.22 unneeded global symbols

Richard B. Johnson (
Mon, 27 Jan 1997 19:48:21 -0500 (EST)

On Mon, 27 Jan 1997, Alan Cox wrote:

> > \begin{C-Legalese}
> > If you pass the address of object to another compilation unit
> > (i.e. source file), this object does not need to be extern; it
> > can be static or allocated (but NOT automatic).
> > \end{C-legalese}


It CAN be automatic if its LIFETIME has not expired.

int *wherever()
int were_it_was; /* Automatic variable */

/* Perfectly valid */
ioctl(0, DO_SOMETHING, &where_it_was);
/* This is NOT */

After a return, or after you "run-off-the-end" (in which the compiler
does the return for you), the lifetime of automatic variables has
expired. More 'C' legalese defines not only the size and types of
objects, but also their lifetimes.

Note that calling a variable "static" makes its lifetime forever,
because it is no longer allocated on the stack. Therefore these
objects continue to occupy valuable RAM. This might not always be
good. Therefore, just changing everything to "static" is not useful.

However, making procedures static, if they are only referenced from
a single file, reduces linker overhead because these symbols are not
present in the output file. Of course making global variables static
makes certain that somebody else doesn't reference one of your variables.

Dick Johnson
Richard B. Johnson
Project Engineer
Analogic Corporation
Voice : (508) 977-3000 ext. 3754
Fax : (508) 532-6097
Modem : (508) 977-6870
Ftp :
Email :,
Penguin : Linux version 2.1.21 on an i586 machine (66.15 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.