__ACTION
2015-06-11 13:21

报错: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.
按照老师后面的步骤,先定义一个max.h头文件,然后在hello.c中写入该头文件就好了
这个需要请教高手~
貌似高端。
Linux C语言编程基本原理与实践
204636 学习 · 469 问题
相似问题