- 论坛徽章:
- 0
|
有三个.c文件
==================
helper.c
==================
#include <stdio.h>
void msg1(void)
{
printf("the message sent from Jupiter1\n");
}
=================
helper2.c
=================
#include <stdio.h>
void msg2(void)
{
printf("the message sent from Jupiter2\n");
}
================
hello.c:
================
#include <stdio.h>
int main()
{
printf("Hello,Linuxprogramming world!\n");
msg1();
msg2();
return 0;
}
其中hello.c 调用了helper.c和helper2.c中的函数,但没有包含对应的helper.h和helper2.h头文件(事实上我也没有建立这两个头文件);
使用 gcc helper.c helper2.c hello.c -o hello 可以编译生成hello文件并正常运行打印出
Hello,Linuxprogramming world!
the message sent from Jupiter1
the message sent from Jupiter2
我的疑问是,为什么在hello.c中不用msg1()和msg2()的头文件,编译为什么可以通过呢?编译器怎么知道到那个文件里面去找这两个函数的定义呢?
|
|