I'm running this in 64-bit system -- the memory map of the struct is
offset: variable
0: op num
2: 00 00 // only 2 paddings
4: label0
8: label1
...
20: label5
sizeof(struct) == 24
// here one could fit an unsigned short between the chars and the first 32-bit integer without affecting the size of the struct.
The rule for struct padding is that any basic variable of width W, will be aligned to that width. Double as second parameter would cause 7 padding bytes after op
and only 3 padding bytes after num
, as labels[0] would then start at an offset divisible by 4.
There's a difference between 32/64 bit systems: 32-bit systems will still align 8-byte variables to 32-bit boundaries. 64-bit systems will align long int and double to 8-byte boundaries.
This would make it safe to use that struct in 32-bit system. If there were doubles in the struct, one could still make the structs compatible with careful planning of the variables.