当前位置:文档之家› GCC编译多个C文件

GCC编译多个C文件

GCC编译多个C文件
GCC编译多个C文件

GCC编译多个C文件

下午做了一个小的程序,定义了三个文件:

getop.h,getop.c,calcDemo.c

显然getop.h是针对getop.c的,而在calcDemo.c中要调用到getop.c中的东西。

首先给出每个文件的结构图,为了更简单的说明,函数都空实现。getop.h:

#ifndef _H_GETOP

#define _H_GETOP

intgetch(void);

void ungetch(int c);

intgetop(char s[]);

#endif

getop.c

#include

#include

#define NUMBER '0'

intgetch(void);

void ungetch(int);

intgetop(char s[])

{

return 0;

}

#define BUFSIZE 100

char buf[BUFSIZE];

intbufp =0;

intgetch(void)

{

return 0;

}

voidungetch(int c)

{

}

calcDemo.c

#include

#include

#include "getop.h" //只需这样引用即可

最后,即是利用gcc来编译这几个文件:https://www.doczj.com/doc/c46237802.html,alcDemo.c -o output.out 编译后的目标文件即为:output.out

然后执行:./output.out即可

相关主题
文本预览
相关文档 最新文档