多文件编译报错。
报错:warning: implicit declaration of function 'maxNum' is invalid in C99 [-Wimplicit-function-declaration]
代码如下:
是gcc版本问题么?是不是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.