后增量相对于顺序点 [英] Post Increment with respect to Sequence Points

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

问题描述

在没有后增量运营商影响的增加?我所遇到的两种意见:

When does the post increment operator affect the increment? I have come across two opinions:

1)从 http://gd.tuwien.ac .AT /语言/ C /编程-bbrown / c_015.htm

POST方法之后的任何做手术
  赋值操作。

POST means do the operation after any assignment operation.

2)建立更紧密的家,一个<一个href=\"http://stackoverflow.com/questions/4445706/post-increment-and-$p$p-increment-concept/4445841#4445841\">answer对SO (虽然对C ++)说:

2) Closer home, an answer on SO(albeit on C++) says:

...延缓增量
  直到前pression年底
      (下一个序列点)。

... that delays the increment until the end of the expression (next sequence point).

也是如此算后增量操作...

So does the post increment operation...

A)等到达到一个序列点或

A) wait until a sequence point is reached or

B)发生后赋值运算符或

B) happen post an assignment operator or

C)顺序点之前,随时都可能发生?

C) happen anytime before the sequence point?

推荐答案

正确间pretation是C,即得。增量的某个时候发生的下一个序列点之前,特别是C标准(C99,6.5.2.4,2)这样说:

The correct interpretation is C, ie. the increment happens sometime before the next sequence point, specifically the C standard (C99, 6.5.2.4, 2) says this:

更新操作之间不得出现的存储值的副作用
  在previous和下一个序列点。

The side effect of updating the stored value of the operand shall occur between the previous and the next sequence point.

全款报价:

后缀++运算的结果是操作数的值。后的结果是
  获得,该操作数的值被递增。 (即,相应的值1
  类型添加到它。)请参阅加法运算符和复合赋值的讨论
  有关约束的,类型和转换信息和操作上的影响
  指针。更新操作之间不得出现的存储值的副作用
  在previous和下一个序列点。

The result of the postfix ++ operator is the value of the operand. After the result is obtained, the value of the operand is incremented. (That is, the value 1 of the appropriate type is added to it.) See the discussions of additive operators and compound assignment for information on constraints, types, and conversions and the effects of operations on pointers. The side effect of updating the stored value of the operand shall occur between the previous and the next sequence point.

这篇关于后增量相对于顺序点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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