- 论坛徽章:
- 0
|
如题。下面例子我不用头文件一样玩呀。根本没有体现头文件的必要性质呀。
tst.c
int add(int x, int y)
{
int z;
z = x +y;
return z;
}
a_call_tst_.c
int a_add(int x, int y)
{
return add(x,y);
}
b_call_tst_.c
int b_add(int x, int y)
{
return add(x,y);
}
main.c
#include<stdio.h>
int main()
{
printf("sum of a_add %d \r\n",a_add(10,10));
printf("sum of b_add %d \r\n",b_add(20,20));
return 1;
}
makefile:
result:main.o
cc main.o a_call_tst_.o b_call_tst_.o tst.o -o result
main.o:a_call_tst_.o b_call_tst_.o
cc -c main.c
a_call_tst_.o: tst.o
cc -c a_call_tst_.c
b_call_tst_.o: tst.o
cc -c b_call_tst_.c
tst.o:tst.c
cc -c tst.c
clean:
rm -rf *.o
[ 本帖最后由 ronghuahan 于 2008-1-11 11:28 编辑 ] |
|