Lundin wrote:
In ANSI C, float numbers are stored in the same way no matter platform.
BTW: If your application depends on the byte ordering, it is not "fully ansi-c compatible", it depends on some compiler and architecture specifics
Hi,
You may be right I didn't write my program in the past by thinking that I will be able to port it to a different mcu. My application is communicating with WinXP work at a PC that is also little endian. For example, When I need to send a huge stuct to PC, I use that simple method:
Code:
t_huge_struct val; // contains doubles, ints, chars, bitfields, array..etc, ~2000 byteSendMemoryAsHex(&val, sizeof(t_huge_struct));
And decoding it at PC side is easy due to PC and MCU have same memory map for t_huge_struct variable.
Code:
DecodeHexStrMemory(RecvStr, &val); //sizeof(RecvStr) = 2*sizeof(t_huge_struct)
But now, I need to write a interface for whole struct
I wonder if all type casing that is valid in little endian system is also valid in big endian system?
Code:
unsigned int tmp = 125;unsigned char val = (unsigned char)tmp; // val == 125?signed int tmp = -5;signed char val = (signed char)tmp; // val == -5?double tmp = -2134.12;signed int val = (signed int)tmp; // val == -2134?