I'm trying to initialize a struct which has a union inside and am not sure how to do it correctly. The code is part of a bigger GitHub Repository, so I don't want to change the initial code. Here's the Struct :
typedef struct SYP_encoder_stru {
char name[15];
u8 type;
s16 val_min;
s16 val_max;
s16 value;
u8 step;
u8 miditype;
union {
u8 midicc;
u16 midirpn;
u16 midinrpn;
};
u8 mapping;
u16 wordstart;
u16 ebpos;
} SYP_encoder_struct;
If I want to create an Encoder Struct in another file, would this be right?:
SYP_encoder_struct enc1 = {
"OSC1 Shape", //name
0, //type
0, //val min
127, //val max
0, //value
1, //stepping
0, //miditype
20, //midicc?? what about midirpn and midinrpn
0, //mapping
0, //wordstart
0 //ebpos
};
I'm just not sure because of the Union. Is this how to initiliaze a struct if it has an union inside? What if I want to initiliaze midirpn or midinrpn instead of midicc?
P.S.: The Code is written in C, sorry forgot to mention.
.midirpn = 37or whatever.