I am working with a generated header file which has the following map between state names and values:
#define START 0
#define IDLE 1
#define RESET 2
etc...
With the given API, I can get the value of the current state. This is fine in most cases, however I would like to get the name of the state to print to a debug console for easy debugging.
Is there any way I can abuse the preprocessor to get the name of the macro when I know its value?
At the moment I have a lookup table between the name and value, but this isn't a great solution since the macros in the header file change when it is regenerated.
I already tried some suggestions from here but didn't have much success.