Stringifying an conditionally compiled enum in C
问题 Our system has a large number of enums denoting stuff such as events, errors etc. I'm trying to build infrastructure that would allow us to log each received event or error message as a string (instead of a plain integer), without having to build and maintain two lists for each enum. I found the X Macro technique quite suitable for my needs. Thus, instead of doing this: typedef enum { valA, valB, valC } some_enum; const char* some_enum_strings[] = { "valA", "valB", "valC" }; I'm doing this: