file1.c
#include <stdio.h>
void z()
{
printf("file1 is used");
return ;
}
void z()
{
printf("file1 is used");
return ;
}
hello.c
#include<stdio.h>
//#include "file1.h"
int main()
{
printf("hello world \n");//ctrl + shift切换输入法
z();
return 0;
}
//#include "file1.h"
int main()
{
printf("hello world \n");//ctrl + shift切换输入法
z();
return 0;
}
gcc -c file1.c -o fiile1.o
gcc -c hello.c -o hello.o
gcc hello.o file1.o -o hello
./hello
注:这样连接的时候不需要在hello.c文件中加入#include"file1.c"