<> wrote:
>/tmp/x.c:7: warning: this decimal constant is unsigned only in ISO C90
I think it was addressed in this thread:
http://tinyurl.com/ytuxdv
># define INT_MIN (-INT_MAX - 1)
># define INT_MAX 2147483647
This produces the warning:
int y = -2147483648;
whereas this does not:
int y = (-2147483647 - 1);
(Interestingly, though, I guess I expected the preprocessor to calculate
the final answer before passing it to the compiler, and it doesn't.
And now, it doesn't even make sense that the preprocessor would do it.
I mean, the compiler has to do that kind of stuff anyway, right?
So why did I have it in the back of my mind that the preprocessor
sometimes did simple math? Some holdover from the olden days of not-so-
optimal compilers?)
Finally,
int y = -0x80000000;
does not produce a warning, though it is the same as -2147483648.
Apparently the rules are different for hex constants than they are for
decimal constants (c99 6.4.4.1p5).
-Beej