K
kelvSYC
Are there any endianness concerns in C++, or does the compiler take
care of those details? I ask because I'm not sure if code such as the
following have consistent behavior on all platforms.
typedef unsigned int u32; // sizeof(int) == 4
typedef unsigned char u8;
u8 array[4] = { 0x01, 0x23, 0x45, 0x67 };
*((u32*) array) = 0x89ABCDEF;
Will array contain { 0x89, 0xAB, 0xCD, 0xEF } or { 0xEF, 0xCD, 0xAB,
0x89 }, or even something else?
care of those details? I ask because I'm not sure if code such as the
following have consistent behavior on all platforms.
typedef unsigned int u32; // sizeof(int) == 4
typedef unsigned char u8;
u8 array[4] = { 0x01, 0x23, 0x45, 0x67 };
*((u32*) array) = 0x89ABCDEF;
Will array contain { 0x89, 0xAB, 0xCD, 0xEF } or { 0xEF, 0xCD, 0xAB,
0x89 }, or even something else?