Compiler Mode

From Free Pascal wiki
Revision as of 19:42, 18 July 2016 by Arent (talk | contribs)
Jump to navigationJump to search

Deutsch (de) English (en) español (es) suomi (fi) français (fr)

The Free Pascal compiler will compile in a specific mode. Each mode dictates what syntax the compiler accepts as valid, and what it considers as invalid. The compiler mode can be set in the source code with the {$mode } compiler directive, or on the command line with the -M command line option.

Modes

  • Free Pascal: {$mode FPC}
    This is the original Free Pascal compiler mode. As of version 3, It is the default mode of the compiler, so it is not necessary to explicitly add this directive.
  • Turbo Pascal: {$mode TP}
    This is the Turbo Pascal compatibility mode.
  • Delphi: {$mode DELPHI}
    This is the Delphi compatibility mode.
  • Mac Pascal: {$mode MacPAS}
    The Mac Pascal compatibility mode.

ModeSwitch

As of version 2.3.1 of Free Pascal, the {$ModeSwitch} compiler directive has been added to allow features of a compiler mode to be selectively added to the current mode, effectively creating a custom mode. For example:

{$mode FPC}
{$ModeSwitch EXCEPTIONS}

Will add exception handling to the FPC compiler mode.

See also