- 论坛徽章:
- 0
|
p79的问题, #if (-1 + 0x0) >> 1 > 0x7fff 不知是如何确定大于16位的,我用VC测试#if (-1 + 0x0) >> 1 > 0x7fff
结果为假.
The presence of <limits .h> is also designed to discourage an old programming
trick that is extremely nonportable. Some programs attempted
to test the properties of the execution environment by writing #if directives:
#if (-1 + 0x0) >> 1 > 0x7fff
/* must have ints greater than 16 bits */
...
#endif
This code assumes that whatever arithmetic the preprocessor performs
is the same as what occurs in the execution environment. Those who deal
heavily with cross compilers know well that the translation environment
can differ markedly from the execution environment. For tricks like this
one to work, theC Standard would have to require that the translator mimic
the execution environment very closely. And translator families with a
common front end would have to adapt translation-time arithmetic to suit
each environment. |
|