I am developing a tool to dump data from variables. I need to dump the variable name, and also the values.
My solution: Store variable name as a string, and print th
Try this.
#define MACRO_VARIABLE_TO_STRING(Variable) ((void) Variable,#Variable)
Code (void) Variable is void conversion which is no-op then there is the comma operator and macro stringify. So the net result is const char* containing variable name with compiler check is variable really exists.
Now you have the name of your variable and you can use printf() to print its value.