Determining machine characteristics (was: IsUnsigned() function?)

Richard A. O'Keefe ok at goanna.cs.rmit.oz.au
Thu Jul 26 11:46:25 AEST 1990


In article <17148 at haddock.ima.isc.com>, karl at haddock.ima.isc.com (Karl Heuer)
provides some nice macros
> 	#define is_twos_complement() ((-2 | -3) == -1)
> 	#define is_ones_complement() ((-1 & -2) == -3)
> 	#define is_sign_magnitude()  ((-1 | -2) == -3)
and says
> I'd also like to be able to do `is_big_endian()' and `is_little_endian()', but
> I think these require run-time code.

It's clear that an arithmetic expression which appears in _code_ must be
evaluated as if evaluated by the target machine, but need arithmetic
expressions in #ifs be evaluated the same way?  Is it possible for
	#if is_ones_complement()
to succeed and
	if (is_ones_complement())
to fail?

-- 
Science is all about asking the right questions.  | ok at goanna.cs.rmit.oz.au
I'm afraid you just asked one of the wrong ones.  | (quote from Playfair)



More information about the Comp.lang.c mailing list