Re:这是怎么回事? [英] Re: how this works ?

查看:82
本文介绍了Re:这是怎么回事?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Keith Thompson写道:

Keith Thompson wrote:


lector< ha *************** @ gmail.comwrites:
lector <ha***************@gmail.comwrites:

> 4月5日晚上7:37,Willem< wil ... @ stack.nlwrote:
>On Apr 5, 7:37 pm, Willem <wil...@stack.nlwrote:

>>或者您只需返回新指针:

node * create_link_list(n)
>>Or you just return the new pointer:

node *create_link_list(n)


一个人可以这样做,但如果你能做到' 'malloc在创建函数中因为有些错误?为此,可能需要返回一个
int(EXIT_SUCCESS / EXIT_FAILURE)进行检查。


One can do that but what if you can''t malloc in create function
because of some error ? For that, it might be necessary to return an
int (EXIT_SUCCESS/EXIT_FAILURE) for checking.



我建议不要使用EXIT_SUCCESS和EXIT_FAILURE作为状态代码

以外的函数。它并不是绝对保证

他们有不同的价值(虽然我从来没有听说过他们没有的系统

)。


I advise against using EXIT_SUCCESS and EXIT_FAILURE as status codes
for functions other than main. It''s not absolutely guaranteed that
they have distinct values (though I''ve never heard of a system where
they don''t).



你的意思是可能有实现EXIT_SUCCESS ==

EXIT_FAILURE?如果是这样,环境如何区分

两个?

You mean that there may be implementations where EXIT_SUCCESS ==
EXIT_FAILURE? If so how will the environment distinguish between the
two?


许多库函数返回零表示成功,非零表示失败;

这是一个合理的惯例。
Many library functions return zero for success, non-zero for failure;
that''s a reasonable convention to follow.

推荐答案

santosh< sa ********* @ gmail.comwrites:
santosh <sa*********@gmail.comwrites:

Keith Thompson写道:
Keith Thompson wrote:

> lector< ha *************** @ gmail.comwrites:
>lector <ha***************@gmail.comwrites:

>> 4月5日下午7:37,Willem< wil ... @ stack.nlwrote:
或者你只是返回新的指针:

node * create_link_list(n)

一个人可以这样做但是如果你不能在malloc中创建函数怎么办
因为有些错误?为此,可能需要返回一个
int(EXIT_SUCCESS / EXIT_FAILURE)进行检查。
>>On Apr 5, 7:37 pm, Willem <wil...@stack.nlwrote:
Or you just return the new pointer:

node *create_link_list(n)

One can do that but what if you can''t malloc in create function
because of some error ? For that, it might be necessary to return an
int (EXIT_SUCCESS/EXIT_FAILURE) for checking.


我建议不要使用EXIT_SUCCESS和EXIT_FAILURE作为状态代码
以用于main以外的功能。它并不是绝对保证
他们有不同的价值(虽然我从来没有听说过他们不喜欢的系统)。


I advise against using EXIT_SUCCESS and EXIT_FAILURE as status codes
for functions other than main. It''s not absolutely guaranteed that
they have distinct values (though I''ve never heard of a system where
they don''t).



你的意思是可能有实现EXIT_SUCCESS ==

EXIT_FAILURE?如果是这样,环境如何区分

两个?


You mean that there may be implementations where EXIT_SUCCESS ==
EXIT_FAILURE? If so how will the environment distinguish between the
two?


>许多库函数返回零表示成功,非零表示失败;
这是一个合理的惯例。
>Many library functions return zero for success, non-zero for failure;
that''s a reasonable convention to follow.



芯片钻头意外切换的可能性更大,然后

他们不是同一个IMO。

There would be more chance of a chip bit accidentally toggling then
them not being the same IMO.


santosh写道:
santosh wrote:

Keith Thompson写道:
Keith Thompson wrote:

> lector< ha *************** @ gmail.comwrites:
>lector <ha***************@gmail.comwrites:

>> 4月5日,7:37 pm,Willem< wil ... @ stack.nlwrote:
或者你只是返回新的指针:

node * create_link_list(n)
一个可以这样做,但如果你因为某些错误而无法在创建函数中使用malloc怎么办?为此,可能需要返回一个
int(EXIT_SUCCESS / EXIT_FAILURE)进行检查。
>>On Apr 5, 7:37 pm, Willem <wil...@stack.nlwrote:
Or you just return the new pointer:

node *create_link_list(n)
One can do that but what if you can''t malloc in create function
because of some error ? For that, it might be necessary to return an
int (EXIT_SUCCESS/EXIT_FAILURE) for checking.


我建议不要使用EXIT_SUCCESS和EXIT_FAILURE作为主要功能以外的功能的状态代码。它并不是绝对保证
他们有不同的价值(虽然我从来没有听说过他们不喜欢的系统)。

I advise against using EXIT_SUCCESS and EXIT_FAILURE as status codes
for functions other than main. It''s not absolutely guaranteed that
they have distinct values (though I''ve never heard of a system where
they don''t).



你的意思是可能有实现EXIT_SUCCESS ==

EXIT_FAILURE?如果是这样,环境如何区分

两个?


You mean that there may be implementations where EXIT_SUCCESS ==
EXIT_FAILURE? If so how will the environment distinguish between the
two?



系统没有要求

能够区分两者。


void main(void)

There is no requirement for the system
to be able to distinguish between the two.

void main (void)


>许多库函数返回零表示成功,非零表示失败;
这是一个合理的惯例。
>Many library functions return zero for success, non-zero for failure;
that''s a reasonable convention to follow.



这是一个很好的约定,因为可能有多种模式的故障可用




对于函数,比如ctype函数,

返回一个概念上是boolean的值,

返回一个成功,零返回失败,make更有意义。


-

pete

That''s a good convention for when there may be
multiple modes of failure available.

For functions, like the ctype functions,
which return a value that is conceptually boolean,
returning one for success and zero for failure, makes more sense.

--
pete


pete写道:
pete wrote:

santosh写道:
santosh wrote:

> Keith Thompson写道:
>Keith Thompson wrote:

>> lector< ha *************** @ gmail.comwrites:
4月5日晚上7:37,Willem< wil ... @ stack.nlwrote:
或者你只是返回新指针:
>
node * create_link_list(n)
一个人可以做到这一点,但如果你不能malloc创建功能因为有些错误?为此,可能需要返回一个int(EXIT_SUCCESS / EXIT_FAILURE)进行检查。
我建议不要使用EXIT_SUCCESS和EXIT_FAILURE作为除main之外的函数的状态代码。它并不是绝对保证
他们有不同的价值(虽然我从来没有听说过他们不喜欢的系统)。
>>lector <ha***************@gmail.comwrites:
On Apr 5, 7:37 pm, Willem <wil...@stack.nlwrote:
Or you just return the new pointer:
>
node *create_link_list(n)
One can do that but what if you can''t malloc in create function
because of some error ? For that, it might be necessary to return
an int (EXIT_SUCCESS/EXIT_FAILURE) for checking.
I advise against using EXIT_SUCCESS and EXIT_FAILURE as status codes
for functions other than main. It''s not absolutely guaranteed that
they have distinct values (though I''ve never heard of a system where
they don''t).


你的意思是可能有EXIT_SUCCESS ==
EXIT_FAILURE的实现?如果是这样,环境将如何区分两个?


You mean that there may be implementations where EXIT_SUCCESS ==
EXIT_FAILURE? If so how will the environment distinguish between the
two?



系统没有要求

能够区分两者。


void main(void)


There is no requirement for the system
to be able to distinguish between the two.

void main (void)



我收不到。从n1256第7.20节第3段:


+ -----

| EXIT_FAILURE

|和

| EXIT_SUCCESS

|

|它扩展为整数常量表达式,可以用作

|退出函数返回不成功或成功的参数

|终止状态,分别到主机环境;

+ -----


以上似乎很清楚地表明EXIT_FAILURE和

EXIT_SUCCESS向主机返回不同的终止状态。如果实现无法区分

它们会如何发生这种情况?


< snip>

I don''t get it. From n1256 section 7.20 para 3:

+-----
| EXIT_FAILURE
| and
| EXIT_SUCCESS
|
| which expand to integer constant expressions that can be used as the
| argument to the exit function to return unsuccessful or successful
| termination status, respectively, to the host environment;
+-----

The above seems to be indicate pretty clearly that EXIT_FAILURE and
EXIT_SUCCESS return different termination statuses to the host. How
could this happen if the implementation could not distinguish between
them?

<snip>


这篇关于Re:这是怎么回事?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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