xHarbour Reference Documentation > Preprocessor Reference |
Compiles a section of code depending on the absence of a #define constant.
#ifndef <constant> <statements1> [ #else <statements2> ] #endif
The #ifdef..#else..#endif directives are used for conditional compilation. They work similar to the IF..ELSE..ENDIF statements, but are resolved by the preprocessor, rather than the compiler. #ifndef tests if a #define constant does not exist. When the constant is undefined, the statements following #ifndef are included in the preprocessor output. When the constant does exist, the statements folowing #else, if present, are used. #endif closes the conditional compilation block.
See also: | #define, #if, #ifdef |
Category: | Preprocessor directives |
// The example demonstrates a common technique used to avoid multiple // inclusion of an #include file. If, by accident, an include file is // included more than once, the directives are skipped by the preprocesor // since the #define constant MY_CH_FILE is created on first inclusion. #ifndef MY_CH_FILE #define MY_CH_FILE <preprocessor directives> #endif
http://www.xHarbour.com