int main() { extern int i; i=20; printf("%d",i); return 0; }
编译器给出了’我’未定义的错误
什么原因?
1.int i; // i is defined to be an integer type in the current function/file 2.extern int i; // i is defined in some other file and only a proto-type is present here.
因此,在编译时,编译器(LDD)将寻找变量的原始定义,如果它没有找到,那么它会向’i’引发错误’未定义的引用.