If you maintain C code, you've probably written enum-to-string conversion functions by hand (either with switch statement, lookup tables or similar).
I wrote about autoamtic enum stringification in C - using build-time code generation from the DWARF debug information that is produced by the GCC/Clang compilers. (Medium, no Paywall).
I found the approach to reduce effort and errors for producing debug printout, logging, parsing config files, etc.
At the end, the developer can write something like:
Sharing in the hope that other developer can use this code. Can be integrated into any code with files (".c" source, ".h" header and python code generator) - available on my GitHub (MIT License).
yairlenga•1h ago
I wrote about autoamtic enum stringification in C - using build-time code generation from the DWARF debug information that is produced by the GCC/Clang compilers. (Medium, no Paywall).
I found the approach to reduce effort and errors for producing debug printout, logging, parsing config files, etc.
At the end, the developer can write something like:
Sharing in the hope that other developer can use this code. Can be integrated into any code with files (".c" source, ".h" header and python code generator) - available on my GitHub (MIT License).Any feedback will be appreciated.