3 ms·
struct fields { uint8_t f1; uint16_t f2; uint8_t f3; } > What do you think the size of this structure is? It should be 4 bytes, right? Of course
by dozzie 9y ago
struct fields {
uint8_t f1;
uint16_t f2;
uint8_t f3;
}
> What do you think the size of this structure is? It should be 4 bytes, right?
Of course not! Ever heard of this "memory alignment" thing? There even were
architectures where accessing an unaligned int would get you SIGBUS
(Solaris/SPARC was one, from what I remember). Have you never wondered where
all the unix signals came from?
- Gibbon1 9y agoYep memory alignment a terrible cancerous idea[1] left over from 80's/90's era RISC machines. [1] Hey lets make the memory layout look like Swiss Cheeze and increase the pressure on the cache! It'll totally be faster!!!