Re: 2.1.22 unneeded global symbols

Thomas Koenig (ig25@fg70.rz.uni-karlsruhe.de)
25 Jan 1997 19:05:51 +0100


In linux.dev.kernel, alan@lxorguk.ukuu.org.uk (Alan Cox) wrote:

>Its wrong. Your script needs to handle inline function export names and
>also assembler and references buried in include files. Also function
>names used as variables and passed directly or indirectly to functions.

If you want to pass a pointer to a variable to somewhere else, it doesn't
have to be extern; it can be made static.

In other words, code like

foo.h:

char *foo_msg(void);

foo.c:

#include "foo.h"

static char msg[]="This is an important message."

char *foo_msg()
{
return msg;
}

is perfectly all right, and doesn't pollute the global namespace with
the variable "msg".

You can pass addresses to static functions the same way.