Thanks. In terms of expect, user normally expects it can read any variable in a struct as normal. For instance, after user set testMsgPtr->k = 10, it should be still 10 when we read it out. However, our test shows it does not work like that.
I understand it is because the hardware that can not handle word reads from odd addresses, but in this case, can msp430-gcc give a compilation error and exit? Your know this code scratch could happen if user want to make packet header as small as possible in wireless sensor networks. The behavior will be hard to understand. WenZhan On Feb 12, 2008 6:08 PM, Chris Liechti <[email protected]> wrote: > 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 > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Mspgcc-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/mspgcc-users >
