ubuntu的gcc 不能用了,什么原因啊?

zy1040703800 2010-07-22 12:55:57
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

yl@ubuntu:~$ gedit 1.c
yl@ubuntu:~$ gcc 1.c
1.c: In function ‘main’:
1.c:10: error: ‘for’ loop initial declarations are only allowed in C99 mode
1.c:10: note: use option -std=c99 or -std=gnu99 to compile your code
yl@ubuntu:~$ ./a.out
bash: ./a.out: 没有该文件或目录
...全文
429 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
steptodream 2010-07-22
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 zy1040703800 的回复:]

引用 13 楼 steptodream 的回复:
好像是你的home里有个隐藏文件.sudo_as_admin_successful
被你删除了

隐藏的我怎么可以删掉?
[/Quote]
隐藏的文件是可以删除的 说不定你不小心删除了呢
手动创建一个 下次就不会出现了
touch ~/.sudo_as_admin_successful
zy1040703800 2010-07-22
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 steptodream 的回复:]
好像是你的home里有个隐藏文件.sudo_as_admin_successful
被你删除了
[/Quote]
隐藏的我怎么可以删掉?
steptodream 2010-07-22
  • 打赏
  • 举报
回复
好像是你的home里有个隐藏文件.sudo_as_admin_successful
被你删除了
zy1040703800 2010-07-22
  • 打赏
  • 举报
回复
就是 应用程序>附件>终端 这样的啊
zy1040703800 2010-07-22
  • 打赏
  • 举报
回复
等你知道了再告诉我吧,结贴了。。
steptodream 2010-07-22
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 zy1040703800 的回复:]

我记得以前没有的啊,不知道什么时候就出现了。
[/Quote]
你是每次从终端进入的时候有?
还是使用的桌面版 启动命令终端的时候有?
zy1040703800 2010-07-22
  • 打赏
  • 举报
回复
我记得以前没有的啊,不知道什么时候就出现了。
steptodream 2010-07-22
  • 打赏
  • 举报
回复
汗 这个我真不知道

我只知道用户从命令行登录的时候会显示/etc/motd里内容
zy1040703800 2010-07-22
  • 打赏
  • 举报
回复
再问一下,每次打开终端时,都有
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

怎么让他不显示啊。
steptodream 2010-07-22
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 ren0065 的回复:]

主席果然经验丰富= =!
[/Quote]
过奖了 从他编译的错误提示里 都能看出来了哇
BrillianceRen 2010-07-22
  • 打赏
  • 举报
回复
这种变成习惯的话,不如直接用g++来做好点。。
steptodream 2010-07-22
  • 打赏
  • 举报
回复
再测试

[root@ns ~]# vi test.c
#include <stdio.h>
int main()
{
int i=0;
for(i=0;i<3;i++){
printf("%d\n",i);
}
return 0;
}
[root@ns ~]# gcc -o test test.c
[root@ns ~]# ./test
0
1
2
BrillianceRen 2010-07-22
  • 打赏
  • 举报
回复
主席果然经验丰富= =!
steptodream 2010-07-22
  • 打赏
  • 举报
回复
测试

[root@ns ~]# vi test.c
#include <stdio.h>
int main()
{
for(int i=0;i<3;i++){
printf("%d\n",i);
}
return 0;
}
[root@ns ~]#gcc -o test test.c
test.c: In function ‘main’:
test.c:4: error: ‘for’ loop initial declaration used outside C99 mode
[root@ns ~]# gcc -o test test.c -std=c99
[root@ns ~]# ./test
0
1
2
steptodream 2010-07-22
  • 打赏
  • 举报
回复
http://topic.csdn.net/u/20091211/16/6e3c8daf-d9f0-417f-ad45-77f0d67dc56c.html
你的for是这样的把 这种循环好像只有C99标准支持
for(int i = 0;i < N; i++)

你写成这样就没事了
int i = 0;
for(i = 0;i < N; i++)

或者编译的时候加-std=c99 or -std=gnu99 选项

19,613

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧