fun.h
int add(int a, int b);
fun.c
#include"fun.h"
int add(int a, int b)
{
return a+b;
}
main.c
#include<stdio.h>
#include"fun.h"
int main()
{
int c = add(2,3);
printf("%d\n",c);
return 0;
}
Makefile
main:main.o fun.o
gcc main.o fun.o -o main
main.o:main.c fun.h
gcc -c main.c -o main.o
fun.o:fun.c fun.h
gcc -c fun.c -o fun.o
clean:
rm -f main *.o