if (_1_HOUR < count_value < _2_HOUR) {...}
This code snippet generates a warning in MPLAB X (It apparently compiles with the XC16 compiler). But I feel it should be an Error. The correct code (IMHO) is:
if ((count_value >_1_HOUR) && (count_value < _2_HOUR)) {...}
I looking for the C programming rule that covers this - does anyone know what that is? Thanks.
Well, it's not. The code is perfectly valid and has defined behavior.
If the result of
1_HOUR < count_value
(which is0
or1
in arithmetic context) is less than_2_HOUR
then{...}
Your X16 compiler probably supports these options that could help you though:
-Wall -Wextra -Werror -pedantic
I'm unsure if it also supports
-pedantic-errors
. The doc was a bit fuzzy.`