這裏是我的一段代碼未定義的引用變量i
#include<stdio.h>
main()
{
extern int i;
i=20;
printf("%d",i);
}
當我編譯它,我得到錯誤
ka2.c: In function ‘main’:
ka2.c:6: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long unsigned int’
/tmp/ccGXrSE5.o: In function `main':
**ka2.c:(.text+0x6): undefined reference to `i'**
collect2: ld returned 1 exit status
我想知道這是我加粗錯誤的線的原因。
您認爲'extern'是什麼意思? – 2011-06-11 17:09:54
警告與代碼不匹配。 -1爲假代碼。 – 2011-06-11 17:18:31
@Rafe Kettler你使用了什麼編譯器我使用Ubuntu 64位和gcc版本4.4.3(Ubuntu 4.4.3-4ubuntu5) – 2011-06-11 17:55:23