This is not supported in C ++, you can expand this into equivalent declarations:
int appliance_id_from_mode[ (MASTER > SLAVE? MASTER : SLAVE) + 1 ] = {}; appliance_id_from_mode[ MASTER ] = 0; appliance_id_from_mode[ SLAVE ] = 1;
Not quite beautiful ... but it should work. If MASTER and SLAVE are enumeration values, you can create a third entry NUMBER_OF_MODES, which avoids the need for cumbersome calculation of the size of the array size ...
source share