Re: How to eliminate the bitmap difference in big endian and little endian?




"Eric J.Hu" <ehu@xxxxxxxxxx> wrote

> Such as I have following bitmap structure and assigned value
> The char value is 0x03 in little endian mode, and the char value is 0xc0
> in big endian mode. How > to eliminate the bitmap difference?
>
You shouldn't normally need to care about the endianness of your host
machine.
You do need to care about the endianness of binary format files.
Never read or write a structure directly to a file that needs to be ported.
Write the functions write16le(int x, FILE *fp) to write a 16-bit
little-endian integer to a file, and so on. Write each field individually.
That way the code works whatever happens to the C compiler's internal
structure layout.


.



Relevant Pages