评论:我的C FAQ页面 [英] Review: My C FAQ Page

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

问题描述

您好c.l.c.


我认为现在是时候提起它了。在过去的2-3个月里,

我一直在努力建立我的C常见问题解答页面,其中包含大约

40 C的问题。很少有人从c.l.c.采用。

同一页面有3个Linux问题,可以忽略。

也是其他几个部分,这里有点OT,并且可以

也被忽略。


(天啊!火焰会倒进......)


-

Vijay Kumar R Zanvar

C常见问题解答 - http://www.geocities.com/vijoeyz/faq/


解决方案

Vijay Kumar R Zanvar写道:

我认为是时候了我提出来了。在过去的2-3个月里,我一直在努力构建我的C FAQ页面,其中包含40个问题。很少有人从c.l.c.采用。
同一页面有3个Linux问题,可以忽略。还有很少的其他部分,这里有点OT,也可以忽略。




不幸的是很大比例您页面上的信息是误导或错误的
。以下是两个例子:


[关于 http://www.geocities.com/vijoeyz/faq/c/struct_cmp.txt]

使用memcmp()比较结构是一个坏主意,因为


"当一个值存储在结构或联合类型的对象中时,

包括在一个成员对象中,该对象的字节为

表示与任何填充字节对应的

未指定的值。 [6.2.6.1]


这意味着memcmp可能表明两个结构不是
相等,即使它们根据成员相等

比较。换句话说,以下内容可能会打印false:


struct {int a; char b; } a = {3,2},b = a;

if(memcmp(& a,& b,sizeof a)== 0)

puts( " true");

else

puts(" false");


[关于 http://www.geocities.com/vijoeyz/faq/c/sizeof_impl.txt

其中宏

#define sizeof_type(类型)(size_t)((类型*)0 + 1)

出现]


这会调用未定义的行为:空指针上的指针算术

未定义。即使算术保证有效,从指针到整数的转换也是实现定义的,并且可能不会给出你期望的结果。


Jeremy。


Vijay Kumar R Zanvar写道:

(哦,天啊!火焰会倒in ...)




现实的态度很好。


这一个
http://www.geocities.com/vijoeyz/faq/knr/1 /swap.txt

与峰会的对面常见问题解答:

第一次交换有多个副作用且

其他两个交换,对于签名的ineger类型有溢出问题。

http://www.eskimo.com/~scs/C-faq/q10.3.html


-

pete


Em周五,2004年2月6日16:17:08 +0530,Vijay Kumar R Zanvar escreveu:

你好clc


你好。

Vijay Kumar R Zanvar
C常见问题解答 - http:/ /www.geocities.com/vijoeyz/faq/




尽管NG中的其他地方出现了问题,但我还是喜欢DMR对
你的一个问题...


-

Quidquid latine dictum sit altum viditur


Hi c.l.c.

I think it''s time that I bring it up. Over the last 2-3 months,
I have been trying to build my C FAQ page which has around
40 C questions. Few of them have been adopted from c.l.c. The
same page has 3 Linux questions, and can be ignored. There
are few other sections, too, which are are a little OT here, and can
also be ignored.

(Oh My God! Flames are gonna pour in...)

--
Vijay Kumar R Zanvar
C FAQs - http://www.geocities.com/vijoeyz/faq/


解决方案

Vijay Kumar R Zanvar wrote:

I think it''s time that I bring it up. Over the last 2-3 months,
I have been trying to build my C FAQ page which has around
40 C questions. Few of them have been adopted from c.l.c. The
same page has 3 Linux questions, and can be ignored. There
are few other sections, too, which are are a little OT here, and can
also be ignored.



Unfortunately a large proportion of the information on your page is
misleading or simply wrong. Here are two examples:

[Regarding http://www.geocities.com/vijoeyz/faq/c/struct_cmp.txt]
Using memcmp() to compare structures is a bad idea, because

"When a value is stored in an object of structure or union type,
including in a member object, the bytes of the object
representation that correspond to any padding bytes take
unspecified values." [6.2.6.1]

This means that memcmp may indicate that two structures are not
"equal", even though they are equal according to a memberwise
comparison. In other words, the following may print "false":

struct { int a; char b; } a = { 3, 2 }, b = a;
if (memcmp(&a, &b, sizeof a) == 0)
puts("true");
else
puts("false");

[Regarding http://www.geocities.com/vijoeyz/faq/c/sizeof_impl.txt,
where the macro
#define sizeof_type( type ) (size_t)((type*)0 + 1 )
appears]

This invokes undefined behaviour: pointer arithmetic on null pointers
is not defined. Even if the arithmetic were guaranteed to work, the
conversion from pointer to integer is implementation-defined and may
not give the results you expect.

Jeremy.


Vijay Kumar R Zanvar wrote:

(Oh My God! Flames are gonna pour in...)



A realistic attitude is good.

This one
http://www.geocities.com/vijoeyz/faq/knr/1/swap.txt
is the opposite of Summits FAQ:
The first swap has unsequenced multiple side-effects and the
other two swaps, have overflow problems for signed ineger types.

http://www.eskimo.com/~scs/C-faq/q10.3.html

--
pete


Em Fri, 06 Feb 2004 16:17:08 +0530, Vijay Kumar R Zanvar escreveu:

Hi c.l.c.

Hi.
Vijay Kumar R Zanvar
C FAQs - http://www.geocities.com/vijoeyz/faq/



Despite the problems pointed elsewhere in this NG, I liked DMR''s answer to
your One Question...

--
Quidquid latine dictum sit altum viditur


这篇关于评论:我的C FAQ页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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