为了账号安全,请及时绑定邮箱和手机立即绑定

提示这,哪里有误

In file included from hello.c:2:0:
test.c: In function 'say':
test.c:3:5: warning: implicit declaration of function 'printLine' [-Wimplicit-function-declaration]
     printLine();
     ^~~~~~~~~
hello.c: At top level:
hello.c:3:13: warning: conflicting types for 'printLine'
 extern void printLine()     //这里定义的方法对吗?
             ^~~~~~~~~
In file included from hello.c:2:0:
test.c:3:5: note: previous implicit declaration of 'printLine' was here
     printLine();
     ^~~~~~~~~
test.c: In function 'say':
test.c:3:5: warning: implicit declaration of function 'printLine' [-Wimplicit-function-declaration]
     printLine();
     ^~~~~~~~~
/tmp/ccOiLhfJ.o: In function `say':
test.c:(.text+0x0): multiple definition of `say'
/tmp/ccIbjHlD.o:hello.c:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status

正在回答

2 回答

hello.c

extern pl***(){

printf(******);

}

int main(){

say();

return 0;

}

test.c

void pl****();

void say(){

pl****;

printf("*****");

pl****;

}

0 回复 有任何疑惑可以回复我~

倒数第三行 multiple definition of `say',表示say被重复定义了。你看,编程的窗口上有两个文件包。当多个文件包含同一个头文件时,文件中有重名变量,就出现了重复定义的错误。

改错方式:去掉引用test.c文件,或者在所有全局变量前加上static ,声明成静止变量。

3 回复 有任何疑惑可以回复我~
#1

九穗禾

请问如果去掉第二行的引用test.c文件,那么主程序中的say()函数怎么从test.c文件中到hello.c文件中?
2018-08-13 回复 有任何疑惑可以回复我~
#2

慕函数6593663 回复 九穗禾

只有一个main函数,
2018-09-01 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
C语言入门
  • 参与学习       926311    人
  • 解答问题       20799    个

C语言入门视频教程,带你进入编程世界的必修课-C语言

进入课程

提示这,哪里有误

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信