QUESTION: strange behaviour of typedef enum and __attribute__((packed)) using sh-hms-g++ 3.0.3

Fabio Giovagnini fgiovag@tin.it
Wed Dec 11 00:35:00 GMT 2002


Hi everybody,
that's my problem:
if I define
typedef struct ms{
	unsigned long f1;
	unsigned long f2;
	unsigned char f3;
	} __attribute__((packed)) ms_t;

unsigned char test;

...
...
test = sizeof(ms_t);
...
...

i see test == 9;

if I delete attribure specifier, i see test = 12.
This is the expected behaviour !!!!

If I define
typedef enum en {em_f1 = 0, em_f2, em_f3} __attribute__(((packed),aligned(1))) 
em_t;

compiling with sh-hms-g++ 3.0.3 I have an error: missing semicolon ....
instead compiling with sh-hms-gcc 3.0.3 everything works fine and the size is 
the expected size.

If I define
typedef enum en {em_f1 = 0, em_f2, em_f3} em_t 
__attribute__(((packed),aligned(1)));

no compiler error I see with sh-hms-g++ but the size is 4 that's unexpected 
size for this enum type if we suppose the __attribute__ keyword has been 
working.
So I dedice the __attribute__ working in thuis sintax is not working, as 
someone said some time ago.

Does anyone have some tips to understand and solve this problem?

Regards.


------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com



More information about the crossgcc mailing list