当前位置:网站首页>C Expert Programming Chapter 1 C: Through the Fog of Time and Space 1.4 K&R C
C Expert Programming Chapter 1 C: Through the Fog of Time and Space 1.4 K&R C
2022-08-01 21:09:00 【weixin_Guest time】
/*When: 1978
*Who: Steve Johnson
*Event: Writing pcc, a portable C compiler
*Influence: Formed the basis of a generation of C compilers.
*/
/*The evolution of the C language is shown in Figure 1-2.
*1973-3 (early C)--->1976-9 (K&R C)--->1983-9 (ANSI C)(1)
*--->1967 (Simula 67)(2)
*1983 (Ada) (3)
*(1)(2)(3) together form 1985-9 (C++)
*/
/* Software Creed
*An unusual bug
The C language inherited a feature from Algol-68, the compound assignment operator, which allows a recurring operation to be written only once instead of twice, and gives the code generator a hint,That is, operand addressing can be so compact. The original way of writing the compound assignment operator is to write the assignment operator first, and then write the operator. There is a trick in the lexical analyzer of the B language that makes the implementation of =op more efficient than the op= form currently used.Simpler but confusing in this form, it's easy to add
b=-3; //subtract 3 from b
and
b= -3; //assign -3 to b
Confused.
Therefore, this feature has been modified to the form currently in use.As part of the modification, the code formatter program indent
was also modified to determine the obsolete form of the compound assignment operator, and to swap the two to convert it to the corresponding standard
form.This is a very bad decision.
No formatter should modify anything other than whitespace in the program.Unpleasantly, this approach introduces a bug where just about anything (as long as it's not a variable) swaps places with the assignment operator if it appears after the assignment operator.
*/
/* This bug may cause syntax errors, such as
*epsilon=.0001;
*will be replaced with
*epsilon.=0001;
*thisIf the statement fails to pass the compiler, you will immediately find the error
*value=!open; //value is set to the logical inverse of open
*will be silently exchanged to
*value!=open; //Compare unequal value with open
*This statement will compile without changing the value of value
*/
#include
int main() {
int b = 5;
b =- 3; /*从b中减去3*/
printf("b = %d\n",b);
b= -3; /*Assign -3 to b*/
printf("b = %d\n", b);
double epsilon=.0001;
printf("epsilon = %f\n", epsilon);
//can't pass the compiliation
//epsilon.=0001;
printf("epsilon = %f\n", epsilon);
int value = 3, open = 4;
bool result = value =! open; /*value is set to the logical inverse of open*/
printf("!open = %d\n", !open);
printf("result = %d\n", result);
result = value != open; /*value compares unequally with open*/
printf("result = %d\n", result);
return 0;
}
/* output:
*/ /*It seems that the previous problem does not exist now*/
边栏推荐
- pytest:开始使用
- CS-NP白蛋白包覆壳聚糖纳米颗粒/人血清白蛋白-磷酸钙纳米颗粒无机复合材料
- ISC2022 HackingClub white hat summit countdown 1 day!Most comprehensive agenda formally announced!Yuan universe, wonderful!
- tiup mirror
- Kubernetes 如何实现组件高可用
- How to encapsulate the cookie/localStorage sessionStorage hook?
- 位运算简介
- Jmeter实战 | 同用户重复并发多次抢红包
- 98. Embedded controller EC actual combat EC development board development completed
- C专家编程 第1章 C:穿越时空的迷雾 1.1 C语言的史前阶段
猜你喜欢
STAHL touch screen repair all-in-one display screen ET-316-TX-TFT common faults
How to choose Visibility, Display, and Opacity when interacting or animating
人工智能可信安全与评测
空间数据库开源路,超图+openGauss风起禹贡
OSG笔记:设置DO_NOT_COMPUTE_NEAR_FAR,手动计算远近平面
PyQt5 + MySQL5.8 【学生信息管理系统】【增删改查】
R语言进行相关的操作
CS-NP白蛋白包覆壳聚糖纳米颗粒/人血清白蛋白-磷酸钙纳米颗粒无机复合材料
漏洞分析丨HEVD-0x6.UninitializedStackVariable[win7x86]
(七)《数电》——CMOS与TTL门电路
随机推荐
Hiking, cured my mental internal friction
相亲模型与有限状态机
响应式织梦模板清洁服务类网站
织梦发布文章提示body has not allow words错误
正则表达式
【微信小程序】【AR】threejs-miniprogram 安装(76/100)
Imitation cattle forum project
在Cesium中实现与CAD的DWG图叠加显示分析
这些 hook 更优雅的管理你的状态
Get started with Grafana in 15 minutes
记录第一次给开源项目提 PR
OSG笔记:设置DO_NOT_COMPUTE_NEAR_FAR,手动计算远近平面
写给刚进互联网圈子的人,不管你是开发,测试,产品,运维都适用
函数(二)
C专家编程 第1章 C:穿越时空的迷雾 1.1 C语言的史前阶段
C陷阱与缺陷 第7章 可移植性缺陷 7.8 随机数的大小
C Expert Programming Preface
2022年秋招,软件测试开发最全面试攻略,吃透16个技术栈
kubernetes各名词缩写
图片识别商品接口 API:天猫淘宝