www.digitalmars.com         C & C++   DMDScript  

D - align doesn't work?

reply "Pavel Minayev" <evilone omen.ru> writes:
D seems to ignore align() attribute. The following program should
print 12, but it outputs 6:

    import stdio;

    struct vector
    {
    align(4):
     short x;
     short y;
     short z;
    }

    int main(char[][] args)
    {
     printf("%d\n", vector.size);
    }

...or am I doing something wrong?

Also, could you please make it so that align() could be applied
to structs & unions as well? Like this:

    align(1) struct DIB_HEADER ...

Seems a bit more consistent when I want to define alignment
for the entire structure, not its separate members.
Dec 21 2001
parent "Walter" <walter digitalmars.com> writes:
I'll check it out. -Walter

"Pavel Minayev" <evilone omen.ru> wrote in message
news:9vvrti$1g3d$2 digitaldaemon.com...
 D seems to ignore align() attribute. The following program should
 print 12, but it outputs 6:

     import stdio;

     struct vector
     {
     align(4):
      short x;
      short y;
      short z;
     }

     int main(char[][] args)
     {
      printf("%d\n", vector.size);
     }

 ...or am I doing something wrong?

 Also, could you please make it so that align() could be applied
 to structs & unions as well? Like this:

     align(1) struct DIB_HEADER ...

 Seems a bit more consistent when I want to define alignment
 for the entire structure, not its separate members.
Dec 21 2001