Home The C Preprocessor www.imodulo.com · 2003-11-10


[ Up: Conditional Syntax ]
[ Previous: Defined ][ Next: Elif ]

The #else directive can be added to a conditional to provide alternative text to be used if the condition fails. This is what it looks like:

#if expressiontext-if-true
#else /* Not expression */
#endif /* Not expression */

If expression is nonzero, the text-if-true is included and the text-if-false is skipped. If expression is zero, the opposite happens.

You can use #else with #ifdef and #ifndef, too.