[comp.unix.wizards] A challenge -- C preprocessor expression for machine's `endian-ness'?

eric@snark.uu.net (Eric S. Raymond) (02/26/90)

I'm tuning and adapting Ralph Merkle's snefru code for use as a netnews
authentication tag. It would be immensely useful if I could do the following:

#if (<unknown-expression>)
#define LITTLE_ENDIAN		/* machine words have LSB first */
#else
#define BIG_ENDIAN		/* machine words have MSB first */
#endif

For those of you who don't recall, the expression may use constants of
integral type, sizeof(), unary ops - ~ and !, binary ops + - / * << >> == != <
<= > >= & ^ | && ||, the ternary op ?: and casts. Parentheses for grouping
are permitted. Can anyone come up with such an expression?

Please reply by email. Results will be summarized to comp.lang.c.
-- 
      Eric S. Raymond = eric@snark.uu.net    (mad mastermind of TMN-Netnews)