Chapter 2
Using conditionals, messages and macros

The Free Pascal compiler supports conditionals as in normal Turbo Pascal, Delphi or Mac OS 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 define 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

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.

 2.1 Conditionals
  2.1.1 Predefined symbols
 2.2 Macros
 2.3 Compile time variables
 2.4 Compile time expressions
  2.4.1 Definition
  2.4.2 Usage
 2.5 Messages