冗余的回报 [英] Redundant return
问题描述
我在函数末尾看到了冗余的return语句。例如
void init_function(void)
{
a_init();
b_init();
c_init();
返回;
}
我在Red Hat的GCC Compiler 3.2.2中检查了生成的代码Linux它
被忽略,因此使用它无害。
有没有人在任何编译器/平台上遇到任何问题/问题?
I have seen redundant return statements at the end of function. e.g.
void init_function(void)
{
a_init();
b_init();
c_init();
return;
}
I checked the generated code in GCC Compiler 3.2.2 on Red Hat Linux it
is ignored so it not harmful to use this.
Has anybody got any problem/issues with this on any compiler/platform?
推荐答案
4月12日上午5:20,quarkLore < agarwal.prat ... @ gmail.comwrote:
On Apr 12, 5:20 am, "quarkLore" <agarwal.prat...@gmail.comwrote:
我在函数末尾看到了多余的return语句。例如
void init_function(void)
{
a_init();
b_init();
c_init();
返回;
}
我在Red Hat的GCC Compiler 3.2.2中检查了生成的代码Linux它
被忽略,因此使用它无害。
有没有人在任何编译器/平台上遇到任何问题/问题?
I have seen redundant return statements at the end of function. e.g.
void init_function(void)
{
a_init();
b_init();
c_init();
return;
}
I checked the generated code in GCC Compiler 3.2.2 on Red Hat Linux it
is ignored so it not harmful to use this.
Has anybody got any problem/issues with this on any compiler/platform?
如果毫无意义,这是完全有效的。任何没有
处理它的编译器都坏了。
That''s perfectly valid, if pointless. Any compiler that does not
handle it is broken.
4月12日上午6:25,robertwess。 .. @ yahoo.com"
< robertwess ... @ yahoo.comwrote:
On Apr 12, 6:25 am, "robertwess...@yahoo.com"
<robertwess...@yahoo.comwrote:
4月12日上午5:20 ,quarkLore < agarwal.prat ... @ gmail.comwrote:
On Apr 12, 5:20 am, "quarkLore" <agarwal.prat...@gmail.comwrote:
我在函数末尾看到了冗余的return语句。例如
void init_function(void)
{
a_init();
b_init();
c_init();
返回;
}
我在Red Hat的GCC Compiler 3.2.2中检查了生成的代码Linux它
被忽略,因此使用它无害。
I have seen redundant return statements at the end of function. e.g.
void init_function(void)
{
a_init();
b_init();
c_init();
return;
}
I checked the generated code in GCC Compiler 3.2.2 on Red Hat Linux it
is ignored so it not harmful to use this.
有没有人在任何编译器/平台上遇到任何问题/问题?
Has anybody got any problem/issues with this on any compiler/platform?
如果毫无意义,这是完全有效的。
That''s perfectly valid, if pointless.
无意义?也许,也许不是。当然在这种情况下没有代码是
产生的。
另一方面,一种编码风格,你需要一个明确的
返回
都有优势,特别是如果你使用超过
一个退出点。
- William Hughes
任何没有
的编译器
Pointless? Maybe, maybe not. Certainly in this case no code is
produced.
On the other hand, a coding style in which you require an explicit
return
for all functions has advantages, especially if you use more than
one exit point.
- William Hughes
Any compiler that does not
处理它坏了。
handle it is broken.
quarkLore说:
quarkLore said:
我看到了冗余的返回语句功能结束。例如
void init_function(void)
{
a_init();
b_init();
c_init();
返回;
}
我在Red Hat的GCC Compiler 3.2.2中检查了生成的代码Linux它
被忽略,因此使用它无害。
I have seen redundant return statements at the end of function. e.g.
void init_function(void)
{
a_init();
b_init();
c_init();
return;
}
I checked the generated code in GCC Compiler 3.2.2 on Red Hat Linux it
is ignored so it not harmful to use this.
对,有些人重视其纪录片效果。它提醒
的读者,这是一个无效的功能,阻止他毫无意义
思考那么那里的回报值是什么?,还有一些人用它来支付
意味着完成! !唷" :-)
Right, and some people value its documentary effect. It reminds the
reader that this is a void function, stopping him from pointlessly
thinking "so where''s the return value then?", and some people use it to
mean "DONE! Phew!" :-)
有没有人在任何编译器/平台上遇到任何问题/问题?
Has anybody got any problem/issues with this on any compiler/platform?
不,这是完全合法的C并且它没有任何损害。
-
Richard Heathfield
Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk
电子邮件:rjh在上述域名中, - www。
No, it''s perfectly legal C and it does no harm whatsoever.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
这篇关于冗余的回报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!