高手:extern编译出错??
本帖最后由 FengPrince 于 2012-11-30 16:15:13 编辑 For an identi?er declared with the storage-class speci?er extern in a scope in which a prior declaration of that identi?er is visible, if the prior declaration speci?es internal or external linkage, the linkage of the identi?er at the later declaration is the same as the linkage speci?ed at the prior declaration.If no prior declaration is visible, or if the prior declaration speci?es no linkage, then the identi?er has external linkage.
int main()
{
int i;
extern int i;
return ;
}
编译出错,说i无连接,明显跟最后一句话相悖啊!
PS:我承认,这个问题a很无聊。。。
[解决办法]
楼主看的是C标准吧,你可以看看下面这段说明,它可以解释为什么i无连接.
The following identifiers have no linkage: an identifier declared to be anything other than
an object or a function; an identifier declared to be a function parameter; a block scope
identifier for an object declared without the storage-class specifier extern.