免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2052 | 回复: 2
打印 上一主题 下一主题

for help about gcc [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-07-27 09:12 |显示全部楼层 |倒序浏览
假设我们有下面这样的一个程序,源代码如下:
/* main.c */
#include "mytool1.h"
#include "mytool2.h"
int main(int argc,char **argv)
{
mytool1_print("hello");
mytool2_print("hello");
}
/* mytool1.h */
#ifndef _MYTOOL_1_H
#define _MYTOOL_1_H
void mytool1_print(char *print_str);
#endif
/* mytool1.c */
#include "mytool1.h"
void mytool1_print(char *print_str)
{
printf("This is mytool1 print %s\n",print_str);
}
/* mytool2.h */
#ifndef _MYTOOL_2_H
#define _MYTOOL_2_H
void mytool2_print(char *print_str);
#endif
/* mytool2.c */
#include "mytool2.h"
void mytool2_print(char *print_str)
{
printf("This is mytool2 print %s\n",print_str);
}
当然由于这个程序是很短的我们可以这样来编译
gcc -c main.c
gcc -c mytool1.c
gcc -c mytool2.c
gcc -o main main.o mytool1.o mytool2.o


gcc -c main.c
mytool2.c: In function ‘mytool2_print’:
mytool2.c:3: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
mytool2.c:5: error: expected ‘{’ at end of input

gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)

论坛徽章:
0
2 [报告]
发表于 2007-07-27 09:35 |显示全部楼层
Thanks to Jiangge,I have missed the ";" in mytool2.h and mytool1.h .

[ 本帖最后由 japuser 于 2007-7-27 09:36 编辑 ]

论坛徽章:
0
3 [报告]
发表于 2007-07-27 13:23 |显示全部楼层
原文没错,我漏了
void mytool1_print(char *print_str);
后面的分号

抱歉,我的失误,

刚装了FCITX,终于可以用中文了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP