__attribute__((packed)) behavior with gcc and g++ [gcc version 3.2 20020903]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Following peice of code compiles under gcc and reports the size of
struct as 11, as expected.  However g++ just does not like the code
and reports an error 'semicolon missing after enum declaration'
g++ 3.4.1 reports a 'warning: `packed' attribute ignored' and I get
the size of struct as 14.
I'd like to pack structures and cause enums to use mininum possible
space, mostly a single byte, under gcc 3.2.
Arch: i686
------
#include <stdio.h>

#pragma pack(1)
typedef enum {
	Red,
	Green,
	Blue
} __attribute__((packed)) MYENUM;

struct pragma_struct_t {
	char	ch;
	int	val;
	char	ch2;
	long	len;
	MYENUM	color;
};
#pragma pack(0)

int main()
{
	printf("sizeof(struct pragma_struct_t)= %d\n",
	sizeof(struct pragma_struct_t));
	return 0;
}
------

How do I get this to work under g++ 3.2?
Any patches or suggestions?

-Milind



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux