Difference between revisions of "Compiler Mode"
From Free Pascal wiki
Jump to navigationJump to searchLine 1: | Line 1: | ||
− | |||
{{Compiler Mode}} | {{Compiler Mode}} | ||
− | 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|source code]] with the {$mode } [ | + | 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|source code]] with the {$mode } |
+ | [[Compiler directive|compiler directive]], or on the [[Command-line interface|command line]] with the -M [http://www.freepascal.org/docs-html/user/userap1.html command line option]. | ||
== Modes == | == Modes == | ||
− | *Free Pascal: | + | *Free Pascal: [[Mode FPC|<syntaxhighlight lang="pascal" enclose="none"> {$mode FPC} </syntaxhighlight>]] <br/>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. |
− | *Extended Free Pascal: | + | *Extended Free Pascal: [[Mode ObjFPC|<syntaxhighlight lang="pascal" enclose="none"> {$mode OBJFPC} </syntaxhighlight>]]<br/>This mode adds extra functionality to the '''FPC''' mode, including [[Class | classes]], [[Interface|interfaces]] and [[Exceptions|exceptions]]. |
− | *Turbo Pascal: | + | *Turbo Pascal: [[Mode TP|<syntaxhighlight lang="pascal" enclose="none"> {$mode TP} </syntaxhighlight>]] <br/>This is the [[Turbo Pascal]] compatibility mode. |
− | *Delphi: | + | *Delphi: [[Mode Delphi|<syntaxhighlight lang="pascal" enclose="none"> {$mode DELPHI} </syntaxhighlight>]] <br/>This is the [[Delphi]] compatibility mode. |
− | *Mac Pascal: | + | *Mac Pascal: [[Mode MacPas|<syntaxhighlight lang="pascal" enclose="none"> {$mode MacPAS} </syntaxhighlight>]]<br/>The [[Mac Pascal]] compatibility mode. |
− | *ISO 7185 Standard Pascal: | + | *ISO 7185 Standard Pascal: [[Mode iso|<syntaxhighlight lang="pascal" enclose="none"> {$mode ISO} </syntaxhighlight>]]<br/>The ISO 7185 standard compatibility mode. The ISO 7185 standard is also known as [[Standard Pascal]]. |
== ModeSwitch == | == ModeSwitch == | ||
Line 22: | Line 22: | ||
For example: | For example: | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang="pascal"> |
{$mode FPC} | {$mode FPC} | ||
{$ModeSwitch EXCEPTIONS} | {$ModeSwitch EXCEPTIONS} | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | Will add | + | Will add exception handling to the FPC compiler mode. |
==See also == | ==See also == | ||
* [http://www.freepascal.org/docs-html/user/userse33.html Compiler modes] | * [http://www.freepascal.org/docs-html/user/userse33.html Compiler modes] |
Revision as of 11:53, 29 June 2019
│
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.
- Extended Free Pascal:
{$mode OBJFPC}
This mode adds extra functionality to the FPC mode, including classes, interfaces and exceptions.
- 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.
- ISO 7185 Standard Pascal:
{$mode ISO}
The ISO 7185 standard compatibility mode. The ISO 7185 standard is also known as Standard Pascal.
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.