3 ms·
The in-memory representation of bit fields is implementation-defined. Therefore, if you're calling into an external API that takes a uint32_t like in the exampl
by scaredginger 4y ago
The in-memory representation of bit fields is implementation-defined. Therefore, if you're calling into an external API that takes a uint32_t like in the example without an explicit remapping, you may or may not like the results.
In practice, everything you're likely to come across will be little endian nowadays, and the ABI you're using will most likely order your struct from top to bottom in memory, so they will look the same most of the time. However, it's still technically not portable.
- galangalalgol 4y agoI've dealt with oddities talking between big endian powerpc using these. Its been a few years but the difference wasn't just the endianess I think? Still, dealing with the mapping was way easier than masking for large structs. Is big endian really dead now?
- scaredginger 4y agoAs I said, it's also ABI. Though admittedly, endianness would be encompassed by ABI, so it's all really just ABI
- throwawaymaths 4y ago> In practice, everything you're likely to come across will be little endian nowadays The internet?
- scaredginger 4y agoNot really relevant to a discussion about CPUs and compiler implementations...
- hansvm 4y agoIt's a language design feature that makes some sorts of networking code much easier to write. Why wouldn't that be relevant?
- throwawaymaths 4y agoNobody ever writes code for memory mapped network devices!!