I'm using a third party library that has a lot of different error codes. An include files contains a whole bunch of lines like:
#define ABC_INVALID_BUFFER_SIZE 101
#define ABC_INVALID_COMMAND 102
etc.
At runtime, I'm getting various error codes as I'm developing my application. I want to, at runtime, have the application print out messages like "error: ABC_INVALID_COMMAND", instead of it printing "error: 102".
I want to have a translation map of sorts that allows me to convert the numbers to text using map[code].
So what I'm looking for is a mechanism that lets me, at compile time, parse the include file, and convert it into map[102] = string("ABC_INVALID_COMMAND"). I can do this using an awk script, but I'm wondering if there is a mechanism that already exists. Surely I can't be the first that wants/needs to do this? Something obvious I haven't discovered yet?