- 论坛徽章:
- 0
|
原帖由 wangxustf 于 2007-11-20 23:04 发表 ![]()
.h头文件怎么和.c文件共同使用,.h文件在linux里打不开
Give you an example
- [root@localhost cu]# cat a1.h
- #ifndef _A_H
- #define _A_H
- void fun(int);
- #endif
- [root@localhost cu]# cat a1.c
- #include<stdio.h>
- #include"a1.h"
- int main()
- {
- int i = 10;
- fun(i);
- return 0;
- }
- [root@localhost cu]# cat a2.c
- #include<stdio.h>
- void fun(int i)
- {
- printf("i=%d\n", i);
- }
- [root@localhost cu]# gcc -c a1.c
- [root@localhost cu]# gcc -c a2.c
- [root@localhost cu]# gcc a1.o a2.o -o out
- [root@localhost cu]# ./out
- i=10
复制代码 |
|