Many programming languages support conditional compilation. Typically compiler directives define or "undefine" certain variables; other directives test these variables and modify compilation accordingly. For example, not using an actual language, the compiler may be set to define "Macintosh" and undefine "PC", and the code may contain:
(* System generic code *)ifmac!=Nullthen(* macOS specific code *)elseifpc!=Null(* Windows specific code *)
In C and some languages with a similar syntax, this is done using an '#ifdef' directive.
When conditional compilation depends on too many variables, it can make the code harder to reason about as the number of possible combinations of configuration increases exponentially.[2][3][4] When conditional compilation is done via a preprocessor that does not guarantee syntactically correct output in the source language, such as the C preprocessor, this may lead to hard-to-debug compilation errors,[5][6][7] which is sometimes called "#ifdef hell."[8][9]