Hi People,
Does anybody sees a means to compute this at compile time? Using the
same trick as we did for SIZEOF etc.
The current test program is
int
main ()
{
/* Are we little or big endian? From Harbison&Steele. */
union
{
long l;
char c[sizeof (long)];
} u;
u.l = 1;
exit (u.c[sizeof (long) - 1] == 1);
}
we rely on the exit to know the result. Basically, we want to do more
or less:
int
main ()
{
/* Are we little or big endian? From Harbison&Steele. */
union
{
long l;
char c[sizeof (long)];
} u;
u.l = 1;
{
int array [1 - 2 * (u.c[sizeof (long) - 1] == 1)]
}
}
or something along these lines. I feel incompetent. Isn't possible
to play with << or >>?