The Free Pascal compiler supports conditionals as in normal Turbo Pascal. It does, however, more
than that. It allows you to make macros which can be used in your code, and it allows you to
de ne messages or errors which will be displayed when compiling. It also has support for
compile-time variables and compile-time expressions, as commonly found in Mac OS
compilers.
The various conditional compilation directives ($IF, $IFDEF, $IFOPT are used in combination with
$DEFINE to allow the programmer to choose at compile time, which portions of the code should be
compiled. This can be used for instance for
- To choose an implementation for one operating system over another.
- To choose a demonstration version or a full version.
- To distinguish between a debug version and a version for shipping.
These options are then chosen when the program is compiled, including or excluding
parts of the code as needed. This is opposed to using normal variables and running
through selected portions of code at run time, in which case extra code is included in the
executable.