Steve McIntyre <[EMAIL PROTECTED]> wrote: > >I would call this default behavior of GCC a bug. > > > >I'll try to verify this with the C99 standard, but in case GCC is able > >to create working code at all (using __attribute__((packed))), it seems like > >the default behavior does not make sense. > > > >Note that countless C-programs depend on sizeof(struct something) returning > >useful values. > > In what way are these not useful values? They may not be what you > expect, but It's a long-known feature of C that making assumptions > about structure layout and alignment _will_ bite you.
Well, it returns size numbers of for unused space. > The default behaviour here is (apparently) as specified by the > designers of the hardware in this case. Alignment _really_ matters for > performance on some architectures, and this is one of them. The usual way to deal with this kind of alignement problems in C is to add alignement _before_ the next var - not after the last var and counting the numbers to inapropriate places. > The quick-hack fix is to use the __attribute__((packed)) patch; the > real fix is to stop depending on structure setup like this - use a > byte array and work within that as appropriate. Then must existing software would be void. Do you really intend this? Jörg -- EMail:[EMAIL PROTECTED] (home) Jörg Schilling D-13353 Berlin [EMAIL PROTECTED] (uni) [EMAIL PROTECTED] (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily