fuTest.c
#include<stdio.h>
void FuTest1(){
printf("%s", "test1");
}
void FuTest2(){
printf("%s", "test2");
}
void FuTest3(){
printf("%s", "test3");
}
func.h
#include<stdio.h>
void FuTest1();
void FuTest2();
void FuTest3();
hello.c
#include<stdio.h>
#include "func.h"
int main(){
FuTest2();
return 0;
}
gcc hello.c fuTest.c -o h
//a.c
#include <stdio.h>
int funa( int n )
{
printf("n=%d\n", n );
return n*2 ;
}
//main.c
#include <stdio.h>
extern int funa(int); //声明funa为外部函数
void main()
{
int x=5,y;
y=funa(x);
printf("y=%d\n", y );
}
在linux下,编译方法为:gcc main.c a.c -o test
在windows下,可建立一个工程,将两个文件添加到该工程中,编译,运行即可