Its the processor which specifies endianness as its the processor which ends up storing the values (upto 64-bits) in memory.
However, you shouldn't need to worry about this, you should be storing variables in a known endian regardless of processor your application is working on.
Eg. instead of:
int a;
write(&a, sizeof(a));
int a;
write(&a, sizeof(a));
To copy to clipboard, switch view to plain text mode
you would use something like:
typedef unsigned int ui32;
typedef unsigned char uc8;
ui32 a;
ui8 c;
c = a >> 24; write (&c, 1);
c = a >> 16; write (&c, 1);
c = a >> 8; write (&c, 1);
c = a;
write (&a, 1);
typedef unsigned int ui32;
typedef unsigned char uc8;
ui32 a;
ui8 c;
c = a >> 24; write (&c, 1);
c = a >> 16; write (&c, 1);
c = a >> 8; write (&c, 1);
c = a;
write (&a, 1);
To copy to clipboard, switch view to plain text mode
then you know you've just written out as MSB (big endian) and guarantee that it will always be MSB regardless. It also guarantees that you'll also always write out 32 bits, regardless if the host OS has a 16-bit int (of course there maybe other consequences of this if you actually use all 32-bits)
Bookmarks