Patterns to escape the #ifdef hell
Christopher Preschern · 2019
There are many things one can do wrong when using the C pre-processor's #ifdef statements. Such statements are often used to distinguish between hardware variants or operating system variants in the C code and when not used carefully, the C code easily becomes a mess of #ifdef cascades. This paper addresses this issue and provides best practices in form of patterns on how to organize variants in C code and on how to get rid of #ifdef statements.