digitalmars.D.learn - structure alignment
- Adam Sansier (8/8) Jul 11 2016 I need to align every member of every struct in a module. I can't
- Adam D. Ruppe (6/13) Jul 12 2016 Right. To align the members, you put align(x) on the individual
- Adam Sansier (7/20) Jul 12 2016 Because god said so.. I can't change it, not everything is in my
- Adam D. Ruppe (3/6) Jul 12 2016 This is trivial, just add it to the bindings.
- Adam Sansier (9/16) Jul 12 2016 It's not trivial, a global modifier similar to pragma(align(n))
I need to align every member of every struct in a module. I can't simply add align(n) inside every struct because that seems ridiculous. I could search and paste, but then D is missing a relatively important aspect of alignment. I have about 100 struct's to align, member wise. From what I've read, align(n){ struct x; } only aligns the struct itself, is this true? Is there a way to set global alignment for members per module or per scope?
Jul 11 2016
On Tuesday, 12 July 2016 at 00:20:31 UTC, Adam Sansier wrote:I need to align every member of every struct in a module. I can't simply add align(n) inside every struct because that seems ridiculous.Why are these structs needing the alignment?From what I've read, align(n){ struct x; } only aligns the struct itself, is this true?Right. To align the members, you put align(x) on the individual members (or align(x): at the top of the struct to apply to all of them)Is there a way to set global alignment for members per module or per scope?no
Jul 12 2016
On Tuesday, 12 July 2016 at 14:26:54 UTC, Adam D. Ruppe wrote:On Tuesday, 12 July 2016 at 00:20:31 UTC, Adam Sansier wrote:Because god said so.. I can't change it, not everything is in my control.I need to align every member of every struct in a module. I can't simply add align(n) inside every struct because that seems ridiculous.Why are these structs needing the alignment?Um, because that's the way they were defined! So your telling me that D is going to make me mark every member align(n) when C++ has a global pragma align that does it for all in the scope? I thought D was better than C++?From what I've read, align(n){ struct x; } only aligns the struct itself, is this true?Right. To align the members, you put align(x) on the individual members (or align(x): at the top of the struct to apply to all of them)Is there a way to set global alignment for members per module or per scope?no
Jul 12 2016
On Tuesday, 12 July 2016 at 14:54:25 UTC, Adam Sansier wrote:Um, because that's the way they were defined! So your telling me that D is going to make me mark every member align(n) when C++ has a global pragma align that does it for all in the scope?This is trivial, just add it to the bindings. :s/struct \(.*\) {/struct \1 {\ralign(1):
Jul 12 2016
On Tuesday, 12 July 2016 at 15:08:29 UTC, Adam D. Ruppe wrote:On Tuesday, 12 July 2016 at 14:54:25 UTC, Adam Sansier wrote:It's not trivial, a global modifier similar to pragma(align(n)) would be trivial. Your method makes many assumptions that may not hold. What if the struct is templated(possible), what if it has comments after struct and before {, etc? It's a hack that is not a solution. The proper solution is to have a way to properly specify that a struct has all members aligned without having to specify it on all members or per struct.Um, because that's the way they were defined! So your telling me that D is going to make me mark every member align(n) when C++ has a global pragma align that does it for all in the scope?This is trivial, just add it to the bindings. :s/struct \(.*\) {/struct \1 {\ralign(1):
Jul 12 2016