请问这句代码什么意思?(复合语句)
<br /><blockquote><br />incr = align >> PAGE_SHIFT ? : 1;<br /></blockquote><br />是否它等价于<br /><blockquote><br />incr = align >> PAGE_SHIFT ? (align >> PAGE_SHIFT) : 1;<br /></blockquote>语句没问题,
<blockquote><br />The middle operand in a conditional expression may be omitted. Then if the first operand<br />is nonzero, its value is the value of the conditional expression.<br />Therefore, the expression<br />x ? : y<br />has the value of x if that is nonzero; otherwise, the value of y.<br />This example is perfectly equivalent to<br />x ? x : y<br />In this simple case, the ability to omit the middle operand is not especially useful. When it<br />becomes useful is when the first operand does, or may (if it is a macro argument), contain a side effect. Then repeating the operand in the middle would perform the side effect twice.<br />Omitting the middle operand uses the value already computed without the undesirable<br />effects of recomputing it.<br /></blockquote><br />This is GCC Extensions to the C Language Family 看好lz.
页:
[1]