struct field alignment
Denis Koroskin
2korden at gmail.com
Sun Oct 17 19:16:53 PDT 2010
On Mon, 18 Oct 2010 06:00:49 +0400, Walter Bright
<newshound2 at digitalmars.com> wrote:
> http://www.digitalmars.com/d/2.0/attribute.html#align
>
> Over time, it has become clear to me that there are only two useful
> alignments:
>
> align // set to whatever the C ABI alignment is
> align(1) // pack everything in, no alignment padding
>
> I think any other alignments should be deprecated. Note that with
> align(1), any alignment is achievable simply by adding in byte fields
> where desired.
On some platforms it is desired to align struct Vec { float[4] data; } on
16 bytes. I don't recall why now, but I know for sure we do that for all
platforms (other than PC maybe). I guess that has something to do with
vector operations.
Bikeshed note: how about align(C) to be consistent with both align(1) and
extern(C)?
More information about the Digitalmars-d
mailing list