Jocke P <> wrote in message news:<bifo0s$bbe$>...
> struct MachineEndian
> {
> enum { is_big = ('B' == (char)(int)'Big ') };
> };
>
> - and it "works" (ie is 0) on my little-endian machine.
Why do you call that working? If we assume for the sake of argument
(NOT TRUE!) that '1234' depends on endianness, then it should work
like this:
little endian: '1234' = 0x34333231
big endian: '1234' = 0x31323334
So your test failed.
If that isn't clear, consider:
#include <stdio.h>
int main(void)
{
char a[5]="1234";
int i = *(int*)a;
int j = '1234';
// does i == j ?
printf("i=0x%x, j=0x%x", i, j);
return 0;
}
By the way, Intel assemblers use the "big endian" definition of
'1234'.
Sam
|