首页 > 其他 > 详细

GCC 多文件编辑

时间:2014-10-09 00:13:18      阅读:223      评论:0      收藏:0      [点我收藏+]
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即可

来源于:http://www.cnblogs.com/hdchild/archive/2009/11/07/1598178.html

GCC 多文件编辑

原文:http://www.cnblogs.com/yingsi/p/4011945.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!