Hi,
I have a problem when using __attribute((packed)) for a struct under
msp430 (telosb).
This is the struct I have
typedef struct{
uint32_t interval;
}start_args_t;
typedef struct{
uint32_t time;
}set_time_args_t;
typedef struct{
uint8_t type;
union{
start_args_t startArgs;
set_time_args_t setTimeArgs;
}args;
}Cmd_t __attribute((packed)) ;
Without the "packed" attribute the struct has a sizeof 6 and padding in
this way
type 1 byte
0x00 padding byte
args 4 bytes
With the "packed" attibute the struct has a sizeof 5, but the variable
type and the args starts at the same address. I mean that if I set first
the args and then the type field, I am rewriting the LSB of the args
field.
If I change the struct to this one
typedef struct{
union{
start_args_t startArgs;
set_time_args_t setTimeArgs;
}args;
uint8_t type;
}Cmd_t __attribute((packed)) ;
The "packet" attribute behaves well. It seems like if the odd field are at
the end of the struct de packing behaves well.
I wonder if this a compiler related bug or I am missing something.
thanks in advance,
-Bill
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help