Conditional compiling Foundation
One fundamental strength of the preprocessor is the ability to compile source code differently depending on defined symbolic constants and their values. Based on whether or not a constant is defined, different parts of a source code file are compiled using #ifdef or #ifndef. To compare values the more complex #if can be used.
This is a sample how to use #ifdef.
Conditional compilation is done using the directives #ifdef, #ifndef, #else and #endif, which provide branching for the preprocessor. When the directives #ifdef and #ifndef are used, the preprocessor tests whether a symbolic constant is defined. Depending on the existence of the #define constant, the preprocessor translates various parts of the source code. In the example, the program can be compiled in two different language versions based on whether the GERMAN_LANGUAGE constant is defined. The section of the source code that is not appropriate is removed and does not exist in the preprocessed code received by the compiler.
This is a sample how to use #if. The .prg file is compiled by calling xpp /dTARGET_VER=0 test.prg.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.