Using C ++ 0x, you can use initializer lists to make this simpler:
const std::map<std::string, signal_t> signal_map{ {"SIGSTOP", SIGSTOP }, {"SIGKILL", SIGKILL }, ... };
This will give you a card with less code to write. If you want, you can also use some preprocessing magic to get the code even easier and not write multiple times. But more often than not, abuse of the preprocessor simply leads to the fact that the code is less useful, and not the best code. (Note that preprocessing magic can still be used if you decide not to use C ++ 0x and continue on your way).
source share