WenZhan Song schrieb:
Our group are using tinyos with msp430 and find the msp430-gcc compiler can not handle packed struct correctly. See the below code scratch and test results. I wonder whether this will be fixed in near future. typedef struct tTestPointer
  {
    uint8_t m;
    uint16_t k;
    uint32_t l;
  } __attribute__ ((packed)) tTestPointer;

it is the hardware that can not handle word reads from odd addresses. and for constructs like the above is gcc generating code that reads words.

for the same reason its a bad idea to typecast a byte array to a struct or int array.

what would you expect in this case? terribly inefficient byte reads for the larger integer types?

you can work around the problem with the struct above by inserting a fill byte, ensuring that uint16 and larger types only start of even addresses/offsets.

chris

Reply via email to