Using conditionals, messages and macros
The Free Pascalcompiler supports conditionals as in normal Turbo Pascal, Delphior 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 macOScompilers.
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
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.
- ConditionalsThe rules for using conditional symbols are the same as under Turbo Pascal or Delphi. Defining a symbol goes as follows: {$define Symbol} From this point on in
- MacrosMacros are very much like symbols or compile-time variables in their syntax, the difference is that macros have a value whereas a symbol simply is defined or is
- Compile time variablesIn MacPas mode, compile time variables can be defined. They are distinct from symbols in that they have a value, and they are distinct from macros, in that they
- Compile time expressionsDefinition In addition to the regular Turbo Pascal constructs for conditional compilation, the Free Pascalcompiler also supports a stronger conditional compile
- MessagesFree Pascallets you define normal, warning and error messages in your code. Messages can be used to display useful information, such as copyright notices, a lis
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
