delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/09/10:09:39

From: j DOT aldrich6 AT genie DOT com
Message-Id: <199605091349.AA117329768@relay1.geis.com>
Date: Thu, 9 May 96 13:41:00 UTC 0000
To: djgpp AT delorie DOT com
Mime-Version: 1.0
Subject: Re: Structure size

Reply to message 9189285    from MARTYNAS.KUNI on 05/09/96  3:25AM


>Actually, the above will not even compile under G++. The docs say to append
>__attribute__ ((packed)) to the end of every field, not the structure
>declaration. However, your approach works with GNU C, though it is not
>documented. GNU C++ does not accept it. I like your approach ( no extra
>typing ) and I think G++ does not understand it due to a bug. I've reported
>this to gcc bug list.

Considering the large numbers of people who have discovered that
particular G++ bug, I'd be quite surprised if the GNU folks don't have
thousands of bug reports about it.

However, the __attribute__ ((packed)) is indeed completely documented
under DJGPP, under info/gcc/C Extensions/Type Attributes.  I quote:

`packed'
     This attribute, attached to an `enum', `struct', or `union' type
     definition, specified that the minimum required memory be used to
     represent the type.

     Specifying this attribute for `struct' and `union' types is
     equivalent to specifying the `packed' attribute on each of the
     structure or union members.  Specifying the `-fshort-enums' flag
     on the line is equivalent to specifying the `packed' attribute on
     all `enum' definitions.


John

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019