3 ms·
> but if you are doing packaged structs that should imply you have a reason to tell the compiler you know better I am pretty sure this could have been implemen
by minipci1321 10y ago
> but if you are doing packaged structs that should imply you have a reason to tell the compiler you know better
I am pretty sure this could have been implemented better -- for malloc-ed and statically-allocated structs the compiler can know the alignment of the structure, so should be able to emit optimal code according to each case. Admittedly, probably a very minor improvement.
It is the feeling of surprise at the time that made me react -- this side-effect wasn't documented in GCC manual at the time, and still isn't.
We now have the attribute "aligned", so I am not sure what the code would look like for a struct {} __attribute__((__packed__,__aligned(8))).
- bluGill 10y agoIf the struct is byte, machine word, byte, machine word there is no way to pull that off.