3 ms·
Hint, compile with -Wpacked
by ryanmccullagh 9y ago
Hint, compile with -Wpacked
- ramzyo 9y agoHave to disagree with you here, totally depends on the platform and if you know what you’re doing. Compiling with this option can lead to unaligned memory accesses. On some architectures, most ARM ones for example, unaligned memory accesses lead to hard faults at runtime.
- smitherfield 9y agoYou're thinking of `#pragma pack`. `-Wpadded` just warns about non-optimal layout.
- ramzyo 9y agoWhoops, yes my bad. -Wpacked will just issue the warning, not actually do the packing!
- adrianN 9y agoWait, doesn't the compiler produce the appropriate code for accessing the packed values without using unaligned memory access if the target platform doesn't support that?