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
Shorter way:
#define GET_VARIABLE_NAME(Variable) (#Variable)
test:
#include class MyClass {}; int main(int argc, char* argv[]) { int foo = 0; std::string var_name1 = GET_VARIABLE_NAME(foo); char* var_name2 = GET_VARIABLE_NAME(foo); char* var_name3 = GET_VARIABLE_NAME(MyClass); return 0; }