This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

packed, aligned


Some time ago there was a discussion about packed structs and the fact
that even if you pack a struct, the size of the struct according to
sizeof() might not be the sum of the size of all the components.

Have I summed it up correctly so far?

But to pack a struct means that the padding between the components in the
struct is zero. Does this mean that the only extra padding is always in
the end of the struct, and there is no way to get rid of this padding?

Why would someone want to pack a struct and still have some padding in the
end?

In my opinion there really should be a packing that really packs a struct
and that is portable over all architectures that gcc runs on.

Either you use padding to exactly know where the different parts is or you
use it to save space and don't care about speed. In both cases it makes no
sence to have padding in the end. If you really want padding in the end
you could easily add that yourself, but now there is no way to remove
padding that you don't want.

I'm very interested to know why one have choosen to not force the packed
struct to be of minimal size.

-- 
/Dennis


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]