Hacker News new | past | comments | ask | show | jobs | submit login

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.




I'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?


As I said, it's also ABI. Though admittedly, endianness would be encompassed by ABI, so it's all really just ABI


> In practice, everything you're likely to come across will be little endian nowadays

The internet?


Not really relevant to a discussion about CPUs and compiler implementations...


It's a language design feature that makes some sorts of networking code much easier to write. Why wouldn't that be relevant?


Nobody ever writes code for memory mapped network devices!!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: