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
 int getch(void);
 void ungetch(int c);
 int getop(char s[]);
#endif

getop.c

 

#include <stdio.h>
#include <ctype.h>
#define NUMBER '0'
int getch(void);
void ungetch(int);


int getop(char s[])
{
 return 0;

}

#define BUFSIZE 100
char buf[BUFSIZE];
int bufp =0;

int getch(void)
{
  return 0;
}

void ungetch(int c)
{

}

calcDemo.c

#include <stdio.h>
#include <stdlib.h>
#include "getop.h" //只需这样引用即可

 

最后,即是利用gcc来编译这几个文件:

gcc getop.c calcDemo.c -o output.out

编译后的目标文件即为:output.out

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

 


 

 

 


转载请注明本文地址: GCC编译多个C文件
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值