On Tue, Nov 26, 2013 at 11:49 PM, Thorsten Glaser <t...@mirbsd.de> wrote: > I know that GCC will need the alignment attribute twice in structs, e.g. > > struct foo { > int bar __attribute__((__aligned__(8))); > int baz; > } __attribute__((__aligned__(8)));
That's not true: the alignment of a struct is the largest alignment of any of its members. So the explicit alignment of bar is sufficient. #include <stdio.h> #include <stdlib.h> struct foo { int bar __attribute__((__aligned__(8))); int baz; } __attribute__((__aligned__(8))); struct foo2 { int bar __attribute__((__aligned__(8))); int baz; }; struct foo3 { int bar; int baz; }; struct foo4 { int bar; int baz; } __attribute__((__aligned__(8))); int main(int argc, char *argv[]) { printf("__alignof__(struct foo) = %zu\n", __alignof__(struct foo)); printf("__alignof__(struct foo2) = %zu\n", __alignof__(struct foo2)); printf("__alignof__(struct foo3) = %zu\n", __alignof__(struct foo3)); printf("__alignof__(struct foo4) = %zu\n", __alignof__(struct foo4)); exit(0); } On m68k: __alignof__(struct foo) = 8 __alignof__(struct foo2) = 8 __alignof__(struct foo3) = 2 __alignof__(struct foo4) = 8 On amd64: __alignof__(struct foo) = 8 __alignof__(struct foo2) = 8 __alignof__(struct foo3) = 4 __alignof__(struct foo4) = 8 Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds -- To UNSUBSCRIBE, email to debian-68k-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/camuhmdwv0eudbcutkpsvg4cqtofd33gsjh5peaxcosivzmk...@mail.gmail.com