In C, I can use the preprocessor to convert a enum to its string equivalent.
But is there any clever trick to convert a char* to a enum.
I can use an if statement and a strcmp for each string and return equivalent enum but is there a more elegant way?
Please, don’t do such hackery. You have almost certainly a design flaw.
EDIT: If you really must do this for some reason I hacked together this. The example should also show it’s usage: