From: Antonio Quartulli On 02/12/13 11:24, David Laight wrote:
...
The only solutions are: use the GCC packed attribute, redesign the structures...
It is probably enough to mark the inner structure containing the three byte fields 'packed'. Marking it aligned(1) might also have the desired effect. The outer structure should then be ok. But would need to use a specially named attribute so it doesn't get removed.
This may work with the structures I reported in a previous email, but it is not a good solution for us because we have other more complex substructs that cannot be packed that way.
You really don't want to have structures that need to be (say) 7 bytes long and contain a 32bit value that will always be correctly aligned.
IIRC adding __attribute__((aligned(1))) to a structure isn't the same as marking it 'packed' - it doesn't normally reduce the alignment for structures (but can be used to force a reduced alignment on a structure member - eg a 4byte aligned 64bit integer).
I don't have an arm compiler handy.
I think we will simply duplicate the members and avoid substructs in our packets.
Can be easiest...
David