so im working in an environment (National Instruments) that auto-generates header files for the GUI.
in my GUI, i have 150-some odd LEDs arranged in a matrix to represent a large relay bank. my LEDs are named and sequenced numerically like
PANEL_LED_1
PANEL_LED_2
...
PANEL_LED_150
etc...
which would allow me to easily control the relays in various configurations if i had a one-to-one mapping of the name with the corresponding value
HOWEVER
the freaking environment auto generates all GUI header files, with virtually no rhyme or reason to the sequences, so i wind up with something like this:
#define PANELRAC_LED_141 2
#define PANELRAC_LED_142 3
#define PANELRAC_LED_143 4
#define PANELRAC_LED_144 5
#define PANELRAC_LED_137 6
#define PANELRAC_LED_138 7
#define PANELRAC_LED_139 8
#define PANELRAC_LED_140 9
and don't think you see a pattern here, because it gets mixed up later, and any time a change is made to the GUI and recompiled a brand new GUI header file is generated and the entire sequence can be re-arranged.
so my question is how best can i associate the string of the #define'd name with the corresponding numeric value.
obviously i would like LED_140 to equal 140. but i can't force that to happen, because i can't modify the header without potentially breaking it in the future.
so i've done this,
case PANELRAC_LED_1:
return 1;
case PANELRAC_LED_2:
return 2;
case PANELRAC_LED_3:
return 3;
...
...
case PANELRAC_LED_124:
return 124;
case PANELRAC_LED_125:
return 125;
case PANELRAC_LED_126:
return 126;
case PANELRAC_LED_127:
return 127;
...
etc...
but i don't like it.
i'm trying to think of a way to do it with enum or a linked list, but i'm drawing a blank.
.