树34
2018-04-19 10:41
运行成功 hello.c: In function 'main': hello.c:8:5: warning: implicit declaration of function 'say' [-Wimplicit-function-declaration] say(); ^~~ test.c: In function 'say': test.c:3:5: warning: implicit declaration of function 'printLine' [-Wimplicit-function-declaration] printLine(); 什么鬼?
hello.c里面第三行extern void printLine()
test.c里面第二行加
void printLine();
第三行改成static void say()
在调用外部函数的时候,要先做个调用声明才不会报错。所以hello和test两个文件都需要补充一个函数调用声明。
hello.c
#include <stdio.h>
extern void say();
void printLine() //这里定义的方法对吗?
{
printf("**************\n");
}
int main()
{
say();
return 0;
}
test.c
#include <stdio.h>
extern void printLine();
void say(){
printLine();
printf("I love imooc\n");
printf("good good study!\n");
printf("day day up!\n");
printLine();
}
你写的test.c那个文件没有定义头文件,然后有mian函数的文件里没有调用test的头文件
C语言入门
926460 学习 · 20800 问题
相似问题