Richard said:
(e-mail address removed) said:
What it actually says is: "At any rate, the integer formats used in
preprocessor #if expressions are not necessarily the same as those that
will be used at run time."
Note the phrase 'not necessarily'.
Consider, for example, the case of a cross-compiler, which runs on a
big-endian machine but which compiles code for use on a little-endian
machine. The preprocessor will of course run on the big-endian box (in this
example), so it will use big-endian integers - but the object code will be
executed on the little-endian machine (in this example), so it will use
little-endian integers.
Endianness and host v target issues are all but irrelevant to the
preprocessor
since it deals with values, not objects!
The FAQ's use of the word 'Format' is perhaps misleading. The real
issue
is that the preprocessor performs calculations using only the largest
integer
type(s). Thus, the preprocessor doesn't always evaluate expressions in
the
same way that the same expression would be evaluated in later
translation
phases...
% type ppm1.c
#include <stdio.h>
int main(void)
{
if (-1 == 4294967295)
{
puts("test 1");
}
#if (-1 == 4294967295)
puts("test 2");
#endif
return 0;
}
% acc ppm1.c -o ppm1.exe
ppm1.c: In function `main':
ppm1.c:5: warning: this decimal constant is unsigned only in ISO C90
ppm1.c:5: warning: comparison between signed and unsigned
% ppm1.exe
test 1
%
By rights, this program should either produce both "test 1" and "test
2", or
neither. However, because the preprocessor uses different 'arithmetic'
to
evaluate expressions, my implementation produced only one output line,
even though the two tests were identical.