δΊ 2012-9-12 20:59, Eric Blake ει:
On 09/11/2012 09:05 PM, Wenchao Xia wrote:
Seriously? We require a C99-compliant compiler, which is required to
treat the more compact version identically (all undefined names evaluate
to 0 in the preprocessor), and HACKING doesn't mandate that we spell out
a defined-ness check first. Okay, so configure adds -Wundef to the set
of CFLAGS, but I fail to see why we want -Wundef (that's an
anachronistic warning, only there to help you if you are writing code
portable to K&R).
So if the preprocessor replaced __GNUC__ to 0, is there difference
between these two kinds of macoros?
#if __GNUC__ >= 4
#if defined(__GNUC__) && __GNUC__ >=4
The only difference is whether -Wundef will warn, and I'm trying to
argue that qemu's current use of -Wundef is pointless, as that warning
exists solely for K&R compatibility, not for modern standard-compliant
code correctness.
OK ,then I think
#if __GNUC__ >= 4
....
#else
[warn name space pollution may happen]
#endif
would be better.
--
Best Regards
Wenchao Xia