C Preprocessor Macros - conditionals based upon argument concatenation
问题 I need help with macros, please! Suppose I’ve got the following constants defined #define foo_tacos_tuesday 1 #define foo_tacos 1 #define foo_nachos_wednesday 2 #define foo_nachos 3 I’d like to write a macro that does the following #define MyFancyMacro( arg1, arg2 ) \ #if ( foo_ ## arg1 ## _ ## arg2 != foo_ ## arg1 ) \ foo_ ## arg1 ## _ ## arg2, foo_ ## arg1, So I can set up a mapping table that only maps the mismatching values: static const int mappingTable[] = { MyFancyMacro(tacos, tuesday)