TITLE: Simple symbol table mapping PROBLEM: mikec@plaza.ds.adp.com (Mike Cavalle) enum Symbols { Mothership, Spacesuit }; static const char* symbol_table [] = { "Mothership", "Spacesuit" }; I've been trying to find a method for specifying the mappings more naturally as ordered pairs. Assuming that the mappings will be done at compile time is there a way to specify the mappings as pairs and have the compiler/preprocessor generate the enum{} and the string_table{}? RESPONSE: fjh@munta.cs.mu.OZ.AU (Fergus Henderson), 1 Mar 94 Yes, you can do it with the preprocessor. In one file `symbols.map', put the following: [...] mapping(Mothership) mapping(Spacesuit) /* etc. */ [...] In the other file: #define stringize(a) #a enum Symbols { #define mapping(a) a, #include "symbols.map" #undef mapping LAST_SYMBOL /* terminator */ }; static const char* symbol_table [] = { #define mapping(a) stringize(a), #include "symbols.map" #undef mapping NULL /* terminator */ };