Language Elements and Reference:xpplrm

#include files Foundation

Preprocessor directives can be created anywhere in the source code. They are used by the preprocessor from the point where they are defined and remain valid until the end of the source code file (exception: #define directives can be undefined using #undef). When directives are needed in more than one source code file, they can be contained in separate files. These separate files have the file extension "CH" by default. They are called #include files and can be inserted into a source code file using the directive #include (the default file extension for source code files is "PRG" and they are termed PRG files). As soon as the preprocessor encounters the directive #include in a file, it inserts the specified file at that location:

#include "" 

IF LastAppEvent() == xbeK_RETURN 
   ? "Program is continued" 
ELSEIF LastAppEvent() == xbeK_ESC 
   ? "Program was terminated" 

The file name of the #include file must always be specified in quotation marks in the #include directive. In the example, the preprocessor inserts the file APPEVENT.CH into the PRG file where the #include directive is located, and all the directives from this CH file are then applied to the PRG file. Frequently used directives only need to be written once in a CH file and can then be used in any number of PRG files via #include.

Xbase++ provides many #include files in the \XPPOS2\INCLUDE directory. The most important of these is the STD.CH file. This file contains the directives for the commands of Xbase++. It is inserted into each PRG file by default and does not need to be specified using the #include directive. The STD.CH file is a good source for examples of the various directives and should be read by any programmer desiring a comprehensive understanding of the preprocessor.


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.