I have a problem when trying to return a union type variable from function. The union is defined in a header file called "Dummy.h" like that:
In "Dummy.c", I declared a function called dummy_union() which just saves 0x55 and 0xFF to a "dummy_union" variable "X" and returns it.
Furthermore, Dummy_caller() calls Dummy_Task() and stores its return to a new "dummy_union" variable "var1". Finally, the 2 members of "var1" are printed.
inline dummy_union Dummy_Task(void)
X.A = 0x55;
X.B = 0xFF;
However, both printfs give 0xFF. Does anyone have any idea why?
static dummy_union var1;
printf("member 1 of var1 is %u \n", var1.A);
printf("member 2 of var1 is %u \n", var1.B);