This Technical Note answers the question: 'How to #define the lowest negative number, without getting a compiler warning?'
It applies to the IAR C/C++ Compiler for ARM and some other IAR C/C++ Compilers.
When making a #define with the lowest possible value the IAR C/C++ Compiler issues a warning and changes sign on the value.
#define MIN_VALUE (-2147483648L)
signed long lValue;
lValue = (MIN_VALUE + 1);
Example (32 bit integer)
The string of...
...is interpreted by the Compiler as two parts, first the...
..is interpreted as the "minus operator", and secondly...
...is interpreted as a constant. And that constant is larger than LONG_MAX.
#define MIN_VALUE (-2147483647L - 1)
All product names are trademarks or registered trademarks of their respective owners.