On Friday, 27 June 2025 at 11:23:56 UTC, WraithGlade wrote:
I've read both of the available printed D books in their
entirety (Ali's and Andrei's) and I noticed Andrei's book
(circa ~2010) mentions that the D compiler rearranges the
members of `class` objects to be more optimal by reducing
alignment-induced padding whereas it leaves the
alignment-induced padding of `struct` objects exactly the same
as implied and required by the order in which you've written
the members of the struct.
Lots of things changed since Andrei's book.
I am guessing what you meant is - is there a way to control
struct alignment, right?
The answer is yes - D has a nice way of controlling the
alignment. - Here is a relevant section that explains it in fine
details: https://dlang.org/spec/attribute.html#align