Bitfields, Bit/Little Endian
<<split from http://cboard.cprogramming.com/c-programming/95463-bitfields-bit-little-endian.html >>
Sorry for bringing back an old thread, but I just want to be clarified.
C gives no guarantee of the ordering of fields within machine words, so if you do use them for the latter reason, you program will not only be non-portable, it will be compiler-dependent too. The Standard says that fields are packed into ‘storage units’, which are typically machine words. The packing order, and whether or not a bitfield may cross a storage unit boundary, are implementation defined.
So, does this mean that it is not possible to convert the bitfields endianness, by lets say htonl(), etc.? And do I have to reorder it bit by bit??