2009/2/10 Richard F <[email protected]>:

> Call me a newbie, but is there anything wrong with the following statement?
>
> rtc.time_element.tm_wday = (rtc.time_element.tm_wday < 6) ? 
> rtc.time_element.tm_wday++ : 0;

"Undefined Behavior"
Try to compile this source with all warnings enabled ( -Wall switch)
Something like
    warning: operation on 'rtc.time_element.tm_wday' may be undefined
should appear.
Use pre-increment.

rtc.time_element.tm_wday = (rtc.time_element.tm_wday < 6) ?
++rtc.time_element.tm_wday : 0;

But on my taste

  if( ++rtc.time_element.tm_wday >= 6 ) rtc.time_element.tm_wday = 0;

is better solution (generates smaller code)

-- 
wbr,
ReAl


_______________________________________________
AVR-GCC-list mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to