WTF GCC, why pad my structs?
kahlonel.io
kahlonel.io
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?
[1] Hey lets make the memory layout look like Swiss Cheeze and increase the pressure on the cache! It'll totally be faster!!!