Is there a way to, at runtime, map the value of an enum to the name? (I’m building with GCC.)
I know GDB can do it and I’m willing to use something that’s unportable and mucks with debug data.
Edit: I’m looking for a solution that doesn’t require modifying the original enum declaration nor hand copying all the values out in a mapping function. I already know how to do both of those.
Effectively; I want a function that does whatever GDB does when it formats runtime enum values.
If you don’t want to invest the time to utilize GCCs symbol information, gcc-xml provides you information about C++ sources in a reusable XML format, including enumeration names.
Simplified example… this source:
becomes: