|ARM Technical Support Knowledge Articles|
If you define the maximum negative limit for a given signed type using a
#define or as part of an constant expression, you will get a compiler warning similar to:
Warning: #1134-D: literal treated as "long long"
Consider the example below:
#define LONG_MIN (-2147483648) long foo = LONG_MIN;
The compiler is interpreting the defined value
LONG_MIN as a constant term (
2147483648) and a separate negation operator. In order for the expression type checking to pass, the constant term on the right must be representable as the destination type (
long). Here, the constant term in the expression cannot be represented as a signed integer type (maximum positive
2147483647) hence resulting in a compiler warning.
The workaround is to either represent the maximum negative in its unsigned form or break the constant into multiple terms.
#define LONG_MIN 0x80000000or
#define LONG_MIN (-2147483647-1)
Did you find this article helpful? Yes No
How can we improve this article?