Is there a way to tell D to rearrange struct members or to not rearrange class members?
WraithGlade
wraithglade at protonmail.com
Fri Jun 27 19:55:30 UTC 2025
Thanks for responding to my question and for your time, etc.
I was aware of `align` but as far as I am aware it is orthogonal
to what I'm asking about. The Andrei book says that D
automatically rearranges members of `class`s in memory to avoid
wasting memory due to padding between members whose width is less
than the native CPU word size alignment, whereas `struct`s are
left as is (meaning the members aren't reordered for alignment
padding optimization).
The `align` command specifies alignments but doesn't seem
relevant to automatic rearranging of members for classes.
I'm not sure if D does that or not anymore, since (as you said)
it has been a long while since that book was published.
More information about the Digitalmars-d-learn
mailing list