Directives Foundation
Directives are statements for the preprocessor. The preprocessor translates program code according to translation rules which are defined by directives. The compiler compiles the program code translated from the preprocessor.
A directive is prefixed by the character # followed by a keyword. The following table lists the directives available in Xbase++.
Directive | Description |
---|---|
#command | User-defined command |
#xcommand | User-defined command |
#translate | User-defined translation statement |
#xtranslate | User-defined translation statement |
#define | Define preprocessor constant or pseudofunction |
#undef | Cancel preprocessor constant or pseudofunction |
#ifdef | Test preprocessor constant for conditional |
#ifndef | compilation |
#endif | End of a conditional compilation |
#include | Insert file in program code |
#stdout | Output message during compilation |
#error | Create compiler errors and output message |
The most important directives are #include, #define and #command. The #include directive is used to insert #include files into the program code. #include files generally contain directives and allow directives to be defined only once but used in many program files.
The #define directive defines a preprocessor constant or a symbolic constant. Constants can then be written within the program code as symbolic constants. As an example:
In this line, the constant value 19 is defined for the symbol K_LEFT (Key left, Left arrow key). The symbol K_LEFT can then be used in the program code instead of the constant 19. Preprocessor constants are extremely helpful to the programer, and Xbase++ contains a large number of #include files containing #define constants.
The directive #command defines the translation rules for commands (see next section).
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.