www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

D - align doesn't work?

↑ ↓ ← "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
↑ ↓ → "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