On Wed, 13 Sep 2006, Ricardo Wiggers wrote: > Steve Hosgood escreveu: > > Steve Underwood wrote: > > > > <snip> > >> I'm not > >> sure if MIPs ever changed. Now, the question is, what do people really > >> expect on a thing like the MSP430. > >> > >> If you try something like > >> > >> struct > >> { > >> int x; > >> char y; > >> } xxx[10]; > >> > >> and loop through the array accessing x, all is well. If you pack the > >> structure it fails with mspgcc. The only real difference in the > >> generated code is the loop steps 3 bytes at a time instead of 4. Now, if > >> you try this with the IAR compiler for the MSP430, things still work > >> with the packed structure. However, to achieve that complex code is > >> produced when the structure is packed, and simple code is produced when > >> it is not. Is this something people would like to see in mspgcc? > >> > >> > > > > It's an interesting dilemma. My opinion is that it should do what the > > IAR compiler does, but generate a warning. Alternatively, fail to > > compile with an error message explaining the issue. > > > > The big thing about compiling for compact embedded environments where > > the MSP430 is often found is that there just isn't the code space to > > allow code bloat due to possible user mistakes like packing > > inappropriate structs. A warning would be the least I'd expect. > >
Hi Steve, I think there are situations where it is appropriate to use packed structs. When implementing a network protocol with a fixed frame or packet structure packed structs come in quite handy: struct { long addr; char flags; char data[17]; } my_packet __attribute__((packed)); I have also seen people using unions here in order to apply a different internal structure to a packet fixed in size. In this case application requirements clash with MSP430 alignments. I see the mspgcc compiler to be the one resolving this somehow rather than failing with an error. What do you think? Marten