I still don't understand the align attribute

Trass3r un at known.com
Wed Jun 2 20:59:22 PDT 2010


"align by itself sets it to the default, which matches the default member  
alignment of the companion C compiler."

"align(Integer): Integer specifies the alignment which matches the  
behavior of the companion C compiler when non-default alignments are used"
I don't really understand that sentence.

"struct S
{   align(4) byte a;	// placed at offset 0
     align(4) byte b;	// placed at offset 1

So those align(4)s are completely useless since the default alignment is  
chosen anyways?

"align (1) struct S
{   byte a;	// placed at offset 0
     byte[3] filler1;
     byte b;	// placed at offset 4
     byte[3] filler2;

This is just as I would expect but this leaves no chance to specify  
alignment for individual members, does it?

More information about the Digitalmars-d-learn mailing list