I have union that represent some structures that all uint32 type but with different bit-fields. can i do assignment of one union to other like this:
typedef union foo_u
{
// raw
uint32_t foo32;
// interpretation 1
struct
{
uint16_t a;
uint16_t b;
} foo_flavor1;
//interpretation 2
struct
{
uint32_t a : 16;
uint32_t b : 12;
uint32_t c : 4;
} foo_flavor2;
} foo;
foo a;
foo b;
a.foo32 = 10;
b.foo32 = 30;
b=a;
or i have to do the assignment like this:
b.foo32 = a.foo32;