I know that the size of union in c is the size of the largest member of the union. If I define this union:
union Test1
{
char C; // 1 byte
uint32_t uTest; // 4 bytes
};
The size of such union "Test1" is 4 bytes.
However, if i define union Test2
union Test2
{
char C; // 1 byte
struct
{
char arr[5]; // 5 bytes
}sTest;
uint32_t uT1; // 4 bytes
uint32_t uT2; // 4 bytes
};
here the largest member of union "Test2" is the structure "sTest" which is 5 bytes, then the size of the union "Test2" should be 5 bytes, but the compiler tells that it is 8 bytes !!!
Can someone please explain what the size of union "Test2" should be??
Thanks