In a arduino application i am working on, i need to find a #define that the application don`t really know the "name" of. I have the following defines that have been created by another application (Sigma Studio) included in a header:
#define MOD_PLUGINS_HP81_ALG0_STAGE0_B2_ADDR 4160
#define MOD_PLUGINS_HP81_ALG0_STAGE0_B1_ADDR 4161
#define MOD_PLUGINS_HP81_ALG0_STAGE0_B0_ADDR 4162
.....
#define MOD_PLUGINS_HP71_ALG0_STAGE0_B2_ADDR 4165
Obviously i can see these defines, but there are 500+ of these defines. What is of interest is to be able to use integer with a string to find correct define. Is it possible? I can generate the needed definition string like this:
int channelId = 7;
int presetId = 1;
char knownValue1[15] = "MOD_PLUGINS_HP";
char knownValue2[21] = "_ALG0_STAGE0_B2_ADDR";
int charSize = sizeof(knownValue1) + sizeof(knownValue2) + sizeof(channelId) + sizeof(presetId);
char findThisDef[charSize];
strncpy(findThisDef, knownValue1, charSize);
char buffer[sizeof(channelId)];
sprintf(buffer, "%d", channelId);
char buffer2[sizeof(presetId)];
sprintf(buffer2, "%d", presetId);
strcat(findThisDef, buffer); // Includes channel number
strcat(findThisDef, buffer2); // Includes preset number
strcat(findThisDef, knownValue2);
So now the application knows the char of the define i need "MOD_PLUGINS_HP71_ALG0_STAGE0_B2_ADDR", how can i now fetch the number "4165" to my application?