Open apple-ouyang opened 2 years ago
It seems to be implementation-defined by the C standard although I believe it's consistent across the major compilers that support packed bitfields, I can do some tests for that. For little-endian machines a difference does need to be made (http://mjfrazer.org/mjfrazer/bitfields/), however that is also needed when using bit-wise operators (if the deltas are transferred across platforms).
OSX:
-mno-ms-bitfields
(seems like microsoft might implement it differently)To test:
I look forward to seeing your test results
I've completed testing, with some minor changes it does work across all compilers listed above (check the msvc gobolt link for the final code). I'll create a pull request later
I found a stackoverflow post saying that the bitfield is not portable. The only portable code is using bit-wise operators. So should we change to bit-wise operators? @i404788