Hi folks
The function reference page for RTX tiny os_wait() is slightly confusing. (http://www.keil.com/support/man/docs/tr51/tr51_os_wait.htm)
It specifies using the bar operator to OR events, but in the example it uses a + symbol. All other examples of os_wait also use the + operator.
Is there any difference? which one is more correct?
Thanks
PS: Also Im not new, just haven't posted in a really long time but I dont see any login gate for this forum...am I blind?
event = os_wait (K_SIG + K_TMO, 50, 0);
A '+' is not the same as '|'. However, if K_SIG and K_TMO are bitwise values, a '+' and a '|' will have the same result in this instance.
Even though using a '+' instead of a '|' has the same result, I think it's bad form. The intention is *not* addition, it's bitwise OR.
To make matters worse, the manual says 'Events may be logically ORed using the vertical bar character ('|').' But the 'vertical bar character' is the bitwise OR operator. Whereas the logical OR operator is the double vertical bar. Bad wording and bad example code.
+ often works as an alternative to |, but on the other hand, + often results in egg on the face since + two times creates havoc while an extra | operation doesn't change the result.
So any example where bit values are combined with + should be reported as bugs. And the responsible developer should be tracked down and teached that what looks like correct code and compiles like correct code may still be totally lousy code.
So basically, neither the description or the example is right, and I should use double bar (||), right?
No.
It should be the single bar, for a bitwise or.
Ah, Ok. read back through the posts and see where I made the error. Thanks for clarifying :)