From the MCU Kinetis Builds Reference Manual, I see:
I have a code like:
struct ss
{
char a;
int b __attribute__ ((aligned(1)));
};
I compile it with codewarrior 10.6 and use sizeof() to check the size of this struct, And I found the size is 8, and then I check the address of a and b, found their address still align at 4.
But I mean to make b align at 1, so the size of the struct shall be 5.
Did I misunderstand something or I miss something?
Hello cencong,
In the structure ss ,the longest is the "int b" it is 4 byte ,
so in the (aligned(x)), the x minimum should be 4 , 1 is wrong.
If you write 1, it is default use the 4 to calculate .
Hope it hleps
Have a great day,
Alice
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
So I guess the document description is wrong.