Felix Fietkau <nbd@xxxxxxxx> writes: > On 2018-07-03 08:14, Kalle Valo wrote: >> Pkshih <pkshih@xxxxxxxxxxx> writes: >> >>> On Fri, 2018-06-29 at 10:30 +0300, Kalle Valo wrote: >>>> Pkshih <pkshih@xxxxxxxxxxx> writes: >>>> >>>> > On Tue, 2018-05-29 at 08:18 +0300, Kalle Valo wrote: >>>> >> <pkshih@xxxxxxxxxxx> writes: >>>> >> >>>> > >>>> > Because C2H data is little endian order, the struct will look like >>>> > struct foo { >>>> > #ifdef __LITTLE_ENDIAN >>>> > u8 bar:4; >>>> > u8 koo:4; >>>> > #else >>>> > u8 koo:4; >>>> > u8 bar:4; >>>> > #endif >>>> > } >>>> >>>> With u8 you don't need endian check, right? I would assume that with >>>> both little and big endian bar and koo would be in the same place. >>> >>> I think u8 with bitfield would be different between little and big endian >>> machines. >> >> To me that does not make any sense, I have never heard about bit >> endianness any of the devices I have worked on. > > Unfortunately, the order in which these fields are laid out is different > between big and little endian, even when only dealing with u8. Oh, didn't know that. Can you give some examples about endian problems with u8 bitfields? Still not getting it. Not that it matters, just curious. > That alone is a strong reason to avoid bitfields entirely for anything > shared between the host and something else. Very good to know, thanks. -- Kalle Valo