免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: KBTiller
打印 上一主题 下一主题

特邀专家在线答疑——名不正则言不顺 一网打尽C语言基本概念 [复制链接]

论坛徽章:
2
技术图书徽章
日期:2013-09-04 15:21:51酉鸡
日期:2013-11-01 21:20:20
131 [报告]
发表于 2011-04-28 18:50 |只看该作者
回复 128# KBTiller


其实在于什么是"正确的代码",符合当前编译器的?符合Cxx标准的?符合编译平台的?符合设计意图的?

论坛徽章:
0
132 [报告]
发表于 2011-04-28 19:33 |只看该作者
回复 131# mirnshi


    我认为“正确的代码”是有明确语义的,在标准中明确定义或编译器明确说明的
    而不能根据程序的行为或汇编代码进行推测

论坛徽章:
0
133 [报告]
发表于 2011-04-29 06:45 |只看该作者
本帖最后由 KBTiller 于 2011-04-30 11:00 编辑

3.4.3
undefined behavior
behavior, upon use of a nonportable or erroneous program construct or of erroneous data,for which this International Standard imposes no requirements

NOTE Possible undefined behavior ranges from ignoring the situation completely with unpredictable results, to behaving during translation or program execution in a documented manner characteristic of the environment (with or without the issuance of a diagnostic message), to terminating a translation or execution (with the issuance of a diagnostic message).

EXAMPLE An example of undefined behavior is the behavior on integer overflow.

未定义的行为
基于使用不可移植的或错误的程序结构或使用错误的数据的行为,本国际标准对这种行为没有提出任何要求。

注:   可能的未定义行为范围很广,从无视具体情境得到完全不可预测的结果,到在翻译或程序执行过程具体环境下的有案可查的特定方式的行为(给出或不给出诊断信息),甚至包括结束翻译或执行(发出诊断信息)

例:未定义的行为的一个例子就是整数溢出的行为。
=====================================
C90中的定义
Behavior, upon use of a nonportable or erroneous program construct or of erroneous data, or of indeterminately valued objects, for which this International Standard imposes no requirements.

论坛徽章:
0
134 [报告]
发表于 2011-04-30 12:36 |只看该作者
3.4.4
unspecified behavior
use of an unspecified value, or other behavior where this International Standard provides two or more possibilities and imposes no further requirements on which is chosen in any instance
EXAMPLE An example of unspecified behavior is the order in which the arguments to a function are evaluated.

未说明的行为
使用未说明的值,或本国际标准提出了两种或更多可能性,且在任何情况下都未进一步要求选择哪种的其他行为
例 一个未说明行为的例子是函数实参的求值次序

论坛徽章:
0
135 [报告]
发表于 2011-05-01 18:10 |只看该作者
记得刚刚接触计算机编程语言时,老师一句话就是:将所有的函数用法等都背下来!
呵呵,现在的电子参考书太多,似乎这些背诵的内容都过时了!

基本概念的学习和记忆还是要保留的!

论坛徽章:
0
136 [报告]
发表于 2011-05-02 17:02 |只看该作者
回复 135# jamesbert


    背函数功能恐怕不是什么好办法

论坛徽章:
0
137 [报告]
发表于 2011-05-02 17:18 |只看该作者
3.5
bit
unit of data storage in the execution environment large enough to hold an object that may
have one of two values
NOTE It need not be possible to express the address of each individual bit of an object.


执行环境中数据的存储单位,大到足够保存一个二值数据对象。
注 并不需要可以表示数据对象每一位的地址

论坛徽章:
2
天蝎座
日期:2014-03-28 10:18:052015年亚洲杯之乌兹别克斯坦
日期:2015-02-10 11:32:25
138 [报告]
发表于 2011-05-03 08:41 |只看该作者
记得刚刚接触计算机编程语言时,老师一句话就是:将所有的函数用法等都背下来!
呵呵,现在的电子参考书太 ...
jamesbert 发表于 2011-05-01 18:10



    曾经走过这条路,害人不浅啊

论坛徽章:
0
139 [报告]
发表于 2011-05-03 08:45 |只看该作者
我也报个名~~

论坛徽章:
0
140 [报告]
发表于 2011-05-04 06:14 |只看该作者
3.6
byte
addressable unit of data storage large enough to hold any member of the basic character set of the execution environment
NOTE 1 It is possible to express the address of each individual byte of an object uniquely.
NOTE 2 A byte is composed of a contiguous sequence of bits, the number of which is implementationdefined.
The least significant bit is called the low-order bit; the most significant bit is called the high-order bit.

字节
可寻址的数据存储单位,足够容纳执行环境基本字符的集中任意成员。
注1:数据对象的各字节的地址可唯一地表示。
注2:字节由一系列相邻的位组成,位的数目是实现定义的。最小的有效位被称为低位,最大的有效位被称为高位。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP