分享

GCC编译多个C文件

 Rainboy913 2013-11-28

下午做了一个小的程序,定义了三个文件: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即可

 


 

 

 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多