This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: The pack attribute


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~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]