C99问题 [英] C99 Question

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

问题描述




C99的哪一部分表示不应该使用malloc(3)的返回值



谢谢。


-

Vijay Kumar R Zanvar

我的主页 - http://www.geocities.com/vijoeyz/

解决方案

" Vijay Kumar R Zanvar" < 6 ***** @ hotpop.com>写道:

C99的哪一部分说malloc(3)的返回值不应该被投放?




没有。标准只定义了语言,它不建议

良好的编程风格。


Martin


< blockquote> Vijay Kumar R Zanvar写道:



C99的哪一部分说malloc(3)的返回值不应该是铸造?




同一部分说你不应该把你的猫微波炉。


常规订阅者不推荐使用Castoc malloc在这个新闻组中

因为:


(a)它没有任何好处;

(b)它没有停止发生了什么不好的事情;

(c)它可以(在C90的某些情况下)实际上/导致/坏事

发生。


即使你没有被(a)和(b)一起说服(你可能也应该是b $ b),(c)应该是一个表明者。


malloc函数 - Just Don''t Cast。


-

Richard Hea thfield: bi****@eton.powernet.co.uk

" ; Usenet是一个奇怪的地方。 - Dennis M Ritchie,1999年7月29日。

C FAQ: http://www.eskimo.com/~scs/C-faq/top.html

K& R答案,C书等:< a rel =nofollowhref =http://users.powernet.co.uk/etontarget =_ blank> http://users.powernet.co.uk/eton


你好,

" Richard Heathfield" <在***** @ address.co.uk.invalid>在消息中写道

新闻:3f ****** @ news2.power.net.uk ...

Vijay Kumar R Zanvar写道:

malloc函数 - Just Don''t Cast。
这对我来说可能很愚蠢,但你的意思是不要施展为:

int * i =(int *)malloc(sizeof(int));



那时还有哪些其他解决方案?只分配没有投票?

- 理查德希思菲尔德: bi *** *@eton.powernet.co.uk
Usenet是一个奇怪的地方。 - Dennis M Ritchie,1999年7月29日。
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K& R答案,C书等: http://users.powernet.co.uk/eton



Hi,

Which section of C99 says that return value
of malloc(3) should not be casted?

Thanks.

--
Vijay Kumar R Zanvar
My Home Page - http://www.geocities.com/vijoeyz/

解决方案

"Vijay Kumar R Zanvar" <vi*****@hotpop.com> writes:

Which section of C99 says that return value
of malloc(3) should not be casted?



None. The standard only defines the language, it does not advise on
good programming style.

Martin


Vijay Kumar R Zanvar wrote:

Hi,

Which section of C99 says that return value
of malloc(3) should not be casted?



The same section that says you should not microwave your cat.

Casting malloc is deprecated by the regular subscribers in this newsgroup
because:

(a) it does nothing good;
(b) it doesn''t stop anything bad happening;
(c) it can (in certain circumstances in C90) actually /cause/ something bad
to happen.

Even if you''re not persuaded by (a) and (b) together (which you probably
should be), (c) should be a showstopper.

The malloc function - Just Don''t Cast.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton


Hello,
"Richard Heathfield" <in*****@address.co.uk.invalid> wrote in message
news:3f******@news2.power.net.uk...

Vijay Kumar R Zanvar wrote:
The malloc function - Just Don''t Cast. This might be silly from me, but you mean don''t cast as:
int *i = (int *) malloc(sizeof(int));
?
What other solutions are there then? just assign w/o casting?

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton



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

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