3 ms·
Y'all are missing the point. The difference between xxxxxxba and abxxxxxx is implementation defined, and changes with different architectures even with the sam
by monocasa 2y ago
Y'all are missing the point.
The difference between xxxxxxba and abxxxxxx is implementation defined, and changes with different architectures even with the same compiler.
That means in the "an Internet RFC [...] exactly [specified] the bits" case, you actually need multiple implementations for different architectures to be portable.
So waht you end up having is
struct test_struct {
#if ARCH_BIT_ENDIANNESS == BIG
uint8_t a: 1;
uint8_t b: 1;
uint8_t x: 6;
#else
uint8_t x: 6;
uint8_t b: 1;
uint8_t a: 1;
#endif
};
for every struct for portable code that has to use bitfields with an externally defined bit pattern.
And it's not that goofy of archs that do it the opposite way of x86. PowerPC is a good example.