Hello, in some *.c file I write: union U { unsigned char c[2]; unsigned int i; }u; void fun(void) { u.c[0] = 0x12; u.c[1] = 0x34; } In C51 u.i = 0x1234 but in C166 u.i = 0x3412. I think that in C166 correctly. Whence such difference in a data representation? Thanks.
Cx51 uses "big-endian" (= Motorola) format for integers (read the manual), which explains the difference. See http://www.keil.com/support/man/docs/c51/c51_xe_byteordering.htm
"Whence such difference in a data representation" You must always assume that the internal data representation is implementation-defined! Therefore, if you really need to know what the internal data representation is, you always read the manual!