Deep question for the REAL C GURU's out there ...
Roger Oberholtzer
roger
Thu Feb 24 10:13:23 PST 2005
On Thu, 2005-02-24 at 15:58, Ben Duncan wrote:
> Thanks Kurt ...
>
> <SNIP>
> >
> > Nope. It's a common idiom. Quick, without looking, tell me if the
> > pointer dereference happens before or after ms_counter is incremented.
>
> ohhh ohhh chose me chose me ... I precedence the operators are presented in the order of
> their presentation. Since -> and postfix ++ ARE equal, the deference will happen
> first, then the increment of the value. However, you are right, since the INTENT here is
> to increment the value, and the target of SLAG prolly are NOT going to be such C GURUS's
> - as here on the list -, clarity would be ptr->counter = ptr->counter + 1
update the value: ++(ptr->counter)
update the pointer: (++ptr)->counter
get a new hobby: ++ptr->counter
It is another one of my quirks. I explicitly specify ordering. Never
trust a compiler more than you need to.
+????????????????????????????+???????????????????????????????+
? Roger Oberholtzer ? E-mail: roger at opq.se ?
? OPQ Systems AB ? WWW: http://www.opq.se/ ?
? Nybrogatan 66 nb ? Phone: Int + 46 8 314223 ?
? 114 41 Stockholm ? Mobile: Int + 46 733 621657 ?
? Sweden ? Fax: Int + 46 8 314223 ?
+????????????????????????????+???????????????????????????????+
More information about the Linux-users
mailing list