Unable to access member of anonymous structure inside union -


I am using a union and using an anonymous structure inside it. I want to know how I can use a member of the structure inside it. Like if I want to access the G variable of the structure using the union variable, how can I do this? Please help :)

  typingf union {uint8_t All; Struct {uint8_t G: 1; Uint8_t O_B: 1; Uint8_t unused: 1; Uint8_t W1: 1; Uint8_t W2: 1; Uint8_t Y1: 1; Uint8_t Y2: 1; Uint8_t IAQ: 1; }; } _UNION_VARIABLE;   

I get the compilation error to access the Composition member like below:

  _UNION_VARIABLE sg_RefreshVar; Sg_RefreshVar.G = Wrong;   

Error: # 137 Associations "& lt; Unknown & gt;"

You need to give it a name

  Typefeed Association {Uint8_t All; Struct {uint8_t G: 1; Uint8_t O_B: 1; Uint8_t unused: 1; Uint8_t W1: 1; Uint8_t W2: 1; Uint8_t Y1: 1; Uint8_t Y2: 1; Uint8_t IAQ: 1; } Bit_field; } _UNION_VARIABLE;   

And then you can go

  _UNION_VARIABLE.bit_field.G;    

Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -