Hi,
In C99 draft
Code:
For an identifier declared with the storage-class specifier extern in a scope in which a
prior declaration of that identifier is visible, if the prior declaration specifies internal or
external linkage, the linkage of the identifier at the later declaration is the same as the
linkage specified at the prior declaration. If no prior declaration is visible, or if the prior
declaration specifies no linkage, then the identifier has external linkage.
Here is code
Code:
#include <stdio.h>
int i = 62; /* external linkage */
int
main(void)
{
int i = 26; /* no linkage */
extern int i; /* same as last line? */
printf("%d\n", i);
return 0;
}
This can be compiled successfully and the result is "26". But according to the standard, "extern int i" has external linkage, and printf should print "62" other than "26". What happend here? And my gcc version is 3.4.4 with compilation option -std=c99.