On Wed, 19 Sep 2007, Jens Seidel wrote: > Could you please help me resolving a problem on the m68k architecture? > I'm the maintainer of hex-a-hop, a funny SDL game, which was mainly > written for i386. During my attempts to make it big endian clean I also > added a static assert test which aim was to check for proper alignment > of a data structure. > > I think my test sizeof(Entry)==8 is wrong as it failed on m68k. > Nevertheless I'm nearly sure that this platform doesn't align a char[1] > array on 64 bit boundaries so the code should work :-)
> typedef struct Entry { > int32_t len; > // could there be an alignment gap here? > char name[1]; > } Entry; On m68k, 32-bit quantities must be aligned to 2 bytes. Since sizeof() of a struct always gives a value that's a multiple of the maximum alignment of the individual fields of the struct, you get 6 (5 rounded up to a multiple of 2). Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [EMAIL PROTECTED] 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 [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]