多文件編譯報(bào)錯(cuò)。
報(bào)錯(cuò):warning: implicit declaration of function 'maxNum' is invalid in C99 [-Wimplicit-function-declaration]
代碼如下:
是gcc版本問(wèn)題么?是不是hello.c中要引入max.o?怎么引入?
wubiao@xMac0?cStudy$cat?hello.c? #include?<stdio.h> int?main() { int?a?=?33; int?b?=?20; int?m; m?=?maxNum(a,b); printf("the?max?value?is?%d\n",m); return?0; } wubiao@xMac0?cStudy$cat?max.c? int?maxNum(int?a,int?b) { return?a>b?a:b; } wubiao@xMac0?cStudy$gcc?-c?max.c?-o?max.o wubiao@xMac0?cStudy$ls hello.c????max.c??????max.o??????test.c?????whichDay.c wubiao@xMac0?cStudy$gcc?max.o?hello.c? hello.c:7:6:?warning:?implicit?declaration?of?function?'maxNum'?is?invalid?in?C99?[-Wimplicit-function-declaration] ????????m?=?maxNum(a,b); ????????????^ 1?warning?generated.
2016-01-06
按照老師后面的步驟,先定義一個(gè)max.h頭文件,然后在hello.c中寫入該頭文件就好了
2015-06-11
這個(gè)需要請(qǐng)教高手~
2015-06-11
貌似高端。