为什么写这篇文章?
我相信很多人跟我一样,在使用了C语言很长一段时间之后,都不曾知道C中有个序列点(sequence point)的概念。最近翻阅C标准时发现它是个非常重要的概念,理解了它对于消除对C的诸多疑惑大有裨益,也更能提高代码质量。
什么是副作用?
副作用?什么副作用?我相信很多人一脸懵逼,还以为是吃了什么药产生了什么副作用。那么我现在确确切切地告诉你,副作用(side effect)是C中的一个重要概念!
慢着!不是说介绍序列点吗? 怎么先提副作用呢? -- 嘿!要理解序列点的概念啊,还必须先理解什么是副作用,至于原因,下文会详细说到!
好,那么在C中到底什么是副作用呢?老规矩,先看看标准中怎么说(C11,5.1.2.3/2):
他们都是程序运行时的概念!
参考链接:
《Sequence Points in C》《C sequence points》
《Sequence points》《Sequence points...》
《C语言序列点浅析》(该博客的其它文章要看)
《C语言中的序列点》
《关于Sequence point与Undefined behaviour之间的关系》
《Non-determinism and sequence points in C》
《C/C++中的side effect(负效应) 和sequence point(序列点)》
《C语言 side effect 和 sequence point》
《Sequence Points and Expression Evaluation in C++》
《Order of evaluation》《Order of evaluation》
《sequence point》《Sequence point》
《Sequence points》《Sequence points》《Sequence Points》
《A Guide to Undefined Behavior in C and C++》
《What are the sequence points in a full expression?》
《C语言的副作用》《Sequence Points and Expression Evaluation in C++ 》
《Undefined behavior and sequence points》
《C Programming/Side effects and sequence points》
《A finer-grained specification of sequencing》
《A finer-grained specification of sequencing》《C language mysterious, what are these goods.》
《EXP44-C. Do not rely on side effects in operands to sizeof, _Alignof, or _Generic》《Sequence points》
《序列点在C语言表达式求值中的作用》《Sequence point》
《C pointer aliasing violations and aggressive compiler optimizations.》
《Solving the gcc 4.4 strict aliasing problems》
《C99 Strict Aliasing Rules and Packed Streams》《Strict aliasing and buffer handling》
3541

被折叠的 条评论
为什么被折叠?



