主要没有退货声明 [英] main without a return statement
问题描述
我有一个主要功能如下:
int main(无效)
{
而(TRUE){...}
返回TRUE;
}
我的问题是从未达到返回TRUE,我可以删除
。在这种情况下,编译器(VDSP 5.0)抱怨不可达性
。当我删除它时,它会在没有警告的情况下编译。谢谢,
Amish
axr0284写于11/07/07 10:27,:
我有一个主要功能如下:
int main(void)
{
而(TRUE){...}
返回TRUE;
}
我的问题是因为从未达到返回TRUE,我可以删除
它。在这种情况下,编译器(VDSP 5.0)抱怨不可达性
。当我删除它时,它会在没有警告的情况下编译。谢谢,
是的,你可以删除它。
(顺便提一下,TRUE看起来像一个奇怪的值
从main()返回。唯一完全可移植的返回
值是EXIT_SUCCESS,EXIT_FAILURE和零。)
-
Er*********@sun.com
11月7日上午11:23,Eric Sosman< Eric.Sos ... @ sun.comwrote:
axr0284写于11/07/07 10:27,:
我有一个主要功能如下:
int main(无效)
{
而(TRUE){...}
返回TRUE;
}
我的问题是因为从未达到返回TRUE,我可以删除
吧。在这种情况下,编译器(VDSP 5.0)抱怨不可达性
。当我删除它时,它会在没有警告的情况下编译。谢谢,
是的,你可以删除它。
(顺便提一下,TRUE看起来像是一个奇怪的值
从main()返回。唯一完全可移植的返回
值是EXIT_SUCCESS,EXIT_FAILURE和零。)
-
Eric.Sos ... @ sun.com
忘了添加#define TRUE 1
谢谢答案
axr0284写道:
11月7日上午11:23, Eric Sosman< Eric.Sos ... @ sun.comwrote:
> axr0284写于11/07/07 10:27,:
>>
我有一个主要功能如下:
int main(void)
{
while( TRUE){...}
返回TRUE;
}
我的问题是,因为永远不会返回TRUE,我可以删除它吗?在这种情况下,编译器(VDSP 5.0)抱怨不可达性。当我删除它时,它会在没有警告的情况下编译。谢谢,
是的,你可以删除它。
(顺便提一下,TRUE看起来像是从main()返回的一个奇怪的值。只有完全可移植的返回
值是EXIT_SUCCESS,EXIT_FAILURE和零。)
-
Eric.Sos ... @ sun.com
忘了添加#define TRUE 1
感谢您的回答
1不属于main的标准返回值。正如Eric Sosman写的那样,标准中提到的三个带有
的是0,EXIT_SUCCESS,
和EXIT_FAILURE。
Hi,
I have a main function as follows:
int main(void)
{
while(TRUE) { ... }
return TRUE;
}
my question is since the return TRUE is never reached, can I remove
it. The compiler (VDSP 5.0) is complaining about the non reachability
in this case. When I remove it, it compiles without warning. Thanks,
Amish
axr0284 wrote On 11/07/07 10:27,:Hi,
I have a main function as follows:
int main(void)
{
while(TRUE) { ... }
return TRUE;
}
my question is since the return TRUE is never reached, can I remove
it. The compiler (VDSP 5.0) is complaining about the non reachability
in this case. When I remove it, it compiles without warning. Thanks,Yes, you can remove it.
(Incidentally, TRUE looks like a strange value to
return from main(). The only fully-portable return
values are EXIT_SUCCESS, EXIT_FAILURE, and zero.)
--
Er*********@sun.com
On Nov 7, 11:23 am, Eric Sosman <Eric.Sos...@sun.comwrote:axr0284 wrote On 11/07/07 10:27,:
Hi,
I have a main function as follows:
int main(void)
{
while(TRUE) { ... }
return TRUE;
}
my question is since the return TRUE is never reached, can I remove
it. The compiler (VDSP 5.0) is complaining about the non reachability
in this case. When I remove it, it compiles without warning. Thanks,
Yes, you can remove it.
(Incidentally, TRUE looks like a strange value to
return from main(). The only fully-portable return
values are EXIT_SUCCESS, EXIT_FAILURE, and zero.)
--
Eric.Sos...@sun.comForgot to added the #define TRUE 1
Thanks for the answer
axr0284 wrote:On Nov 7, 11:23 am, Eric Sosman <Eric.Sos...@sun.comwrote:>axr0284 wrote On 11/07/07 10:27,:
>>Hi,
I have a main function as follows:
int main(void)
{
while(TRUE) { ... }
return TRUE;
}
my question is since the return TRUE is never reached, can I remove
it. The compiler (VDSP 5.0) is complaining about the non reachability
in this case. When I remove it, it compiles without warning. Thanks,Yes, you can remove it.
(Incidentally, TRUE looks like a strange value to
return from main(). The only fully-portable return
values are EXIT_SUCCESS, EXIT_FAILURE, and zero.)
--
Eric.Sos...@sun.com
Forgot to added the #define TRUE 1
Thanks for the answer
1 is not among the standard return values from main. The three with
mentioned in the standard are, as Eric Sosman wrote, 0, EXIT_SUCCESS,
and EXIT_FAILURE.
这篇关于主要没有退货声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!