Possible Duplicate:
C++: Print out enum value as text
Say I have an enumeration:
typedef enum MyEnum_
{
MY_ENUM_BLUE,
MY_ENUM_RED,
MY_ENUM_GREEN
} MyEnum;
And that I have a method that gets an "MyEnum" as parameter. I'd like write to log file the value of that MyEnum, but I don't want 0, 1 or 2 to appear there--- I'd like to output the actual enumeration string "MY_ENUM_xxxx", of course without a switch/case block..... and dealing with each value individually.
Is there some trickery or pattern, in c++ or using macros that would help me achieve that?