Redeclaration of Variables extern/static

Ian G Batten igb at fulcrum.bt.co.uk
Tue Apr 9 01:56:35 AEST 1991


C News, amongst other things, has declarations of ``extern int foo;'' in
either a header or towards the top of a file, and later has ``static int
foo;''.  An example is found in libc/datetok.c or libc/getdate.y.  This
compiles happily with V.2, V.3, V.4, SunOS 4.0, gcc -traditional or gcc
in ansi mode.  In the last case it generates a warning about
redeclaration.

On an IBM RS/6000 (it wasn't my idea) in generates an identifier
redeclared error and exits during compilation.  Lint on an RS/6000
merely reports the redeclaration as a warning.  This is great: a C
compilers that objects to code lint merely warns about.

Can anyone quote chapter and verse as to the legality of this?  As I
want to compile C news, can anyone suggest a workaround?  We've had the
RS/6000 for a few days now and kids, I'll now believe any story, however
bad...

ian



More information about the Comp.lang.c mailing list