关于k& r2的问题 [英] question about k&r2

查看:62
本文介绍了关于k& r2的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我一直在阅读k& r2书,所有的例子都已完成

with main()而不是int main章节开头的(无效)和k& r2

1不会返回0所以我也没有。


我做了两次编译如下所示。


$ gcc -std = c89 -Wall exercise_1-9.c -o exercise_1-9

exercise_1-9.c:5:警告:返回类型默认为'int''

exercise_1-9.c:在函数`main''中:

exercise_1-9.c:27:警告:控制到达无效功能结束


$ gcc -std = c99 -Wall exercise_1-9.c -o exercise_1-9

exercise_1-9.c: 5:警告:返回类型默认为'int''

为什么k& r2在main上没有int返回类型,为什么不是c99

在没有返回

值的情况下,我到达了非空函数的末尾。


亲切的问候,

Anthony Irwin

Hi all,

I have been going through the k&r2 book and all the examples are done
with main() instead of int main(void) and k&r2 in the start of chapter
1 does not return 0 so I haven''t yet either.

I did two compiles shown below.

$ gcc -std=c89 -Wall exercise_1-9.c -o exercise_1-9
exercise_1-9.c:5: warning: return type defaults to `int''
exercise_1-9.c: In function `main'':
exercise_1-9.c:27: warning: control reaches end of non-void function

$ gcc -std=c99 -Wall exercise_1-9.c -o exercise_1-9
exercise_1-9.c:5: warning: return type defaults to `int''
Why doesn''t k&r2 have the int return type on main and why doesn''t c99
care that I reached the end of a non-void function without returning a
value.

Kind Regards,
Anthony Irwin

推荐答案

gcc -std = c89 -Wall exercise_1-9.c -o exercise_1-9

exercise_1-9.c:5:警告:返回类型默认为int '

exercise_1-9.c:在函数`main'':

exercise_1-9.c:27:警告:控制到达非空函数的结束

gcc -std=c89 -Wall exercise_1-9.c -o exercise_1-9
exercise_1-9.c:5: warning: return type defaults to `int''
exercise_1-9.c: In function `main'':
exercise_1-9.c:27: warning: control reaches end of non-void function


gcc -std = c99 -Wall exercise_1-9.c -o exercise_1-9

exercise_1-9.c:5:警告:返回类型默认为int'

为什么k& r2在main上没有int返回类型,为什么不是c99

关心我没有返回

值就达到了无效函数的结束。


亲切的问候,

Anthony Irwin
gcc -std=c99 -Wall exercise_1-9.c -o exercise_1-9
exercise_1-9.c:5: warning: return type defaults to `int''
Why doesn''t k&r2 have the int return type on main and why doesn''t c99
care that I reached the end of a non-void function without returning a
value.

Kind Regards,
Anthony Irwin


Anthony Irwin说:
Anthony Irwin said:

为什么k& r2在主$ b上没有int返回类型$ b
Why doesn''t k&r2 have the int return type on main



他们依赖的事实是,如果函数没有显式返回任何

类型,则假设返回int。在我看来,这是一种糟糕的风格。

They rely on the fact that, if a function doesn''t explicitly return any
type, it is assumed to return int. This is, in my opinion, poor style.


以及为什么没有c99

关心我到达了非-void函数没有返回

值。
and why doesn''t c99
care that I reached the end of a non-void function without returning a
value.



它通常会 - 但是他们(愚蠢地?)为main做了特例。


-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上述域名中, - www。

It does, normally - but they (foolishly?) made a special case for main.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.


这篇关于关于k& r2的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆