I have a GCC question about variable alignment. I thought I understood it, but can't get this to work. This code:
uint8 aaa[4];
uint32 *bbb = (uint32 *)&aaa;
generates this warning:
warning: cast increases required alignment of target type [-Wcast-align]
175 | uint32 *bbb = (uint32 *)&aaa;
I've tried several combinations of the aligned() attribute none of which work:
__attribute__((aligned(4))) uint8 aaa[4];
uint8 aaa[4] __attribute__((aligned(4)));
This method fixes it, but it's too ugly (actually the real code is nested structures and adding unions would be difficult):
union {
uint8 aaa[4];
uint32 bbb;
} aaa2;
uint32 *bbb2 = (uint32 *)&aaa2;
Any ideas?