免费注册 查看新帖 |

Chinaunix

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

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:20 |只看该作者
原帖由 japuser 于 2007-7-27 09:12 发表


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 ‘{’ ...



请先对程序显示行号,不然别人还要帮你数行号,程序长了就不好办了。

你的程序我估计是mytool2.h(或它所包含的头文件)不完整,比如缺少一个 #endif 或 } 或 “ 或 ; 等。请再仔细检查

论坛徽章:
0
3 [报告]
发表于 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
4 [报告]
发表于 2007-07-27 09:54 |只看该作者
原帖由 japuser 于 2007-7-27 09:35 发表
Thanks to Jiangge,I have missed the ";" in mytool2.h and mytool1.h .


No thanks,I,however,cannot see the mistake in your previous post,sorry for that i ignored your header files unintentionally.

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
5 [报告]
发表于 2007-07-27 11:07 |只看该作者
原帖由 Jiangge 于 2007-7-27 09:54 发表


No thanks,I,however,cannot see the mistake in your previous post,sorry for that i ignored your header files unintentionally.

我也没看到哪里少分号了,
楼主能不能指出来?

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
6 [报告]
发表于 2007-07-27 11:20 |只看该作者
原帖由 lenovo 于 2007-7-27 11:07 发表

我也没看到哪里少分号了,
楼主能不能指出来?

就是不告你!
嘻嘻~

论坛徽章:
0
7 [报告]
发表于 2007-07-27 11:39 |只看该作者
原帖由 flw 于 2007-7-27 11:20 发表

就是不告你!
嘻嘻~


坦白从宽阿!  

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
8 [报告]
发表于 2007-07-27 12:38 |只看该作者
原帖由 flw 于 2007-7-27 11:20 发表

就是不告你!
嘻嘻~

我狂晕。

论坛徽章:
0
9 [报告]
发表于 2007-07-27 13:23 |只看该作者
原文没错,我漏了
void mytool1_print(char *print_str);
后面的分号

抱歉,我的失误,

刚装了FCITX,终于可以用中文了。

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
10 [报告]
发表于 2007-07-27 14:21 |只看该作者
原帖由 japuser 于 2007-7-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