This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

static declaration follows non-static one


Hello,

On compiling the following code with gcc (Debian 4.7.2-5) 4.7.2

	#include <stdio.h>

	extern int foo(void);

	static int foo(void) { return 271828; }

	int main(void)
	{
	      printf("foo = %d\n", foo());
	      return 0;
	}

the compiler reports the error:

	foo.c:5:12: error: static declaration of âfooâ follows non-static
declaration
	foo.c:3:12: note: previous declaration of âfooâ was here

However, the Standard says:

	If the declaration of an identifier for an object or a function 
	contains the storage-class specifier extern, the identifier has 
	the same linkage as any visible declaration of the identifier 
	with file scope.

Is it a gcc bug or I misunderstand something?

Thanks,

Andrew Makhorin




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]