Occasionally needing to build up configuration tables in C, and having used (and written) macroassemblers in the past, every so often I really miss the ability to define a real live multi-line macro with embedded preprocessor directives.
Fer example, if I'm writing a table entry like so:
#ifdef PIN_OVERTEMP_B
{PIN_OVERTEMP_B, STAT_OVERTEMP_B},
#endif
(because, after all, this may be compiled for a different model of toaster that has no Overtemp B sensor), it would be really nice if I could squinch that all into a single macro invocation, thus:
PIN2STAT(PIN_OVERTEMP_B, STAT_OVERTEMP_B),
and avoid typing the pin name twice, and cluttering up my source file with two lines relating to conditional compilation for each line of actual table entry.
Alas, the original #define mechanism didn't take this into account, and the modern language expansions don't appear to address it.
Sophistercated modern languages generally purport to do away with conditional compilation entirely, and just rely on compile-time optimization... which kinda doesn't work for, e.g., array initializations, nor for situations in which the statically-skipped code contains undefined constants or other such errors.

Comments