At 14:15 2002-11-15 -0800, you wrote:
Mark is dead on with #3... the compiler can decide on its own whim if it wants to assign StrLen's value to len first, or if it wants to do the comparison of len versus zero first. It will often choose to do this differently depending on the optimization level and the code around it.RecordSize=(len=StrLen(Data.Field1))+((len>0)?1:0);3) I'm not at all certain this is even legal C code. You're changing len and evaluating it in the same expression. Which side of the + operator should be evaluated first? You're lucky your monitor didn't blow up. :)
The only C/C++ operators that have an implied order are the shortcut evaluation operators || and &&. If you say
x || y
you are guaranteed that x is completely evaluated before y is evaluated, and you're also guaranteed that if x evaluates to non-zero, the y expression doesn't get evaluated at all. Similar logic applies to the && logical-and operator.
--
Ben Combee <[EMAIL PROTECTED]>
CodeWarrior for Palm OS technical lead
Palm OS programming help @ www.palmoswerks.com
--
For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
