|
From: | David Brown |
Subject: | [avr-gcc-list] Re: Inline vs. ? : operator |
Date: | Sat, 27 Mar 2010 22:02:03 +0100 |
User-agent: | Thunderbird 2.0.0.24 (Windows/20100228) |
Joerg Wunsch wrote:
David Brown <address@hidden> wrote:Evaluating the result of "p |= BIT(b)" means carrying out the or-assign, then reading the value of p and returning it.You're right, I stand corrected.
That's certainly how /I/ interpret the way volatile works in such cases. I believe there is some uncertainty about how it should work in C++ - the same statement /may/ have a different interpretation in C and C++ when volatiles are sort-of read in this way.
All in all, the fact that even experts are not always accurate in such cases suggests that you should stay well away from such code - an explicit "if" is clear, works exactly as intended, and in some cases gives noticeably better code than a logically equivalent "?:" expression.
[Prev in Thread] | Current Thread | [Next in Thread] |