Hello aJ,

Well I can do the same thing with pragma or compiler switch in C++.
It doesn't mean that thing will work if 32-bit ints have to be aligned
on 32-bit boundaries. While nice to have one syntax to do that, it
doesn't fix the "problem" (which I haven't expressed correctly
probably). What good is a packed structure that has misaligned data
members for the platform?

You end up with mutually exclusive goals for different systems: align to (depending on the CPU) 8/16/32/64 bits and make it compact. You just can't have both in all cases.

Generally I would expect you get one of three cases: 1) you need to ship binary struct from one system to another so you need to match a given layout from a different system (in this case avoiding misaligned data is a matter of luck), 2) you never ship the data out of the process (just skip all the align directives and let DMD align stuff correctly as, I think, it does by default) or 3) you need packed data (uses align to align on 8 bits)


Reply via email to