3 ms·
That is all very fine. If the instructions emitted and the instructions implemented both happen to match that, on every chip your code must run on, you got luc
by ncmncm 5y ago
That is all very fine.
If the instructions emitted and the instructions implemented both happen to match that, on every chip your code must run on, you got lucky.
- deleted 5y ago[deleted]
- dfox 5y agoThe point is that if you care about the resulting in-memory layout then you by definition know on what platform the code will run and what is the ABI. If you want to produce same sequence of bytes regardless of underlying platform, then you have to do it by hand with uint8_t[] buffers and explicit shifts and masks. Casting pointer to struct to char* and writing it somewhere is inherently non-portable and this gas nothing to do with bitfields and nothing to do with things like __attributte__((packed)), although both of these things are useful when you want to do that and understand the (non-)portability implications.
- ncmncm 5y agoTotally missing the point. This not about exact bit placement, which is a whole other bag of worms.