For example, suppose we have a union
typedef union {
unsigned long U32;
float f;
}U_U32_F;
Is there any way to set the initial value when declaring this union type variable?
U_U32_F u = 0xffffffff; // Does not work...is there a correct syntax for this?
Use the initialization list:
U_U32_F u = {0xffffffff };
You can set other members except the first one
U_U32_F u = {.f = 42.0 };
For example, suppose we have a union
typedef union {
unsigned long U32;
float f;
}U_U32_F;
Is there a way to set the initial value when declaring this union type variable?
U_U32_F u = 0xffffffff; // Does not work...is there a correct syntax for this?
Use the initialization list:
U_U32_F u = {0xffffffff };
You can set other members except the first one
U_U32_F u = {.f = 42.0 };