Re: Arithmetic Shift

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/10/10 09:33, Ben Pfaff wrote:
> Is it even necessary to drag the preprocessor into it?
> 
>         if (-1 >> 1 == 1)

Yes, good point: in many cases that suffices,
and if it works it's typically better to avoid the
preprocessor.

On 12/10/10 09:17, Andrew W. Nosenko wrote:

> Why do you think that preprocessor should match the
> behavior of compiler???

Because in practice, when they don't, Bad Things Happen,
this being one of the least of the problems.  Generally
speaking, it's not worth worrying about mismatches when
one mixes a preprocessor from source A (or for machine A)
with a compiler from source B (or for machine B).

For example, if LONG_MAX from the preprocessor is less than the
actual maximum long int value supported by the compiler, then
it's better to treat the weird compiler+preprocessor behavior
as being buggy, and to fix the bug rather than contort the
code with some complicated Autoconf test.  Alternatively,
if it's easy, it's even better to modify the code so that
it works regardless of whether LONG_MAX is truly the maximum
long int value; this avoids the need for any Autoconf
or other test.

The situation with -1 >> 1 is similar.

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf


[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux