This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: The pack attribute
- From: Richard Henderson <rth at redhat dot com>
- To: John Kwan <jkwan at mvista dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 10 Sep 2002 11:37:38 -0700
- Subject: Re: The pack attribute
- References: <3D7E2A9F.9325CF8D@mvista.com>
On Tue, Sep 10, 2002 at 10:23:43AM -0700, John Kwan wrote:
> // case 1
> typedef struct {
> unsigned char byte1;
> int i;
> unsigned char byte2;
> } test_struct_1 __attribute__((packed));
Well, you see, the packed attribute here does not apply
to the structure. It applies to the typename, which is
created after the structure is layed out.
Write it like
typedef struct __attribute__((packed)) {
...
} test_struct_1;
or
typedef struct {
...
} __attribute__((packed)) test_struct_1;
We should probably generate a warning for your example; please
file a gnats bug report so this does not get forgotten.
r~