Macro line #
only works inside macros.
You can do something like this:
#include <iostream> #define VNAME(x) #x #define VDUMP(x) std::cout << #x << " " << x << std::endl int main() { int i = 0; std::cout << VNAME(i) << " " << i << std::endl; VDUMP(i); return 0; }
source share