Кажется, что любой переносимый код, использующий битовые поля, различает платформы с прямым и обратным порядком байтов. См. объявление struct iphdr в ядре Linux для примера такого кода.
Here, writing
struct ParsedInt {
беззнаковый int f1: 1;
беззнаковое int f2: 3;
беззнаковое int f3: 4;
};
uint8_t i;
struct ParsedInt * d = & i;
d->f2
is simply a compact and readable way of saying (i>>1) & (1.
However, bit operations are well-defined and work regardless of the architecture. So, how come bitfields are not portable?