Difference between revisions of "global compiler directives"

From Lazarus wiki
Jump to navigationJump to search
(substitute syntaxhighlight legacy)
(→‎Syntax: reword short description to be more accurate)
 
(One intermediate revision by one other user not shown)
Line 5: Line 5:
 
Some are recognized for compatibility only, and have no effect.
 
Some are recognized for compatibility only, and have no effect.
  
== syntax ==
+
== Syntax ==
general:
+
 
 +
General:
 +
 
 
* [[$mode|<syntaxhighlight lang="pascal" inline>{$mode}</syntaxhighlight>]] selects the compiler mode
 
* [[$mode|<syntaxhighlight lang="pascal" inline>{$mode}</syntaxhighlight>]] selects the compiler mode
 
* [[$modeSwitch|<syntaxhighlight lang="pascal" inline>{$modeSwitch}</syntaxhighlight>]] turns on or off specific mode features
 
* [[$modeSwitch|<syntaxhighlight lang="pascal" inline>{$modeSwitch}</syntaxhighlight>]] turns on or off specific mode features
specific:
+
 
* [[$extendedSyntax|<syntaxhighlight lang="pascal" inline>{$extendedSyntax}</syntaxhighlight>]] allows using functions as if they were procedures
+
Specific:
* [[$pointerMath|<syntaxhighlight lang="pascal" inline>{$pointerMath}</syntaxhighlight>]] allows arithmetic operations with pointers (since [[User Changes 2.6.0#The POINTERARITHMETICS mode switch has been replaced with the POINTERMATH directive|FPC 2.6.0]])
+
 
 +
* [[$extendedSyntax|<syntaxhighlight lang="pascal" inline>{$extendedSyntax}</syntaxhighlight>]] enables multiple syntax extensions
 +
* [[$pointerMath|<syntaxhighlight lang="pascal" inline>{$pointerMath}</syntaxhighlight>]] automatically defines operators for new pointer data types (since [[User Changes 2.6.0#The POINTERARITHMETICS mode switch has been replaced with the POINTERMATH directive|FPC 2.6.0]])
 
* [[$openStrings|<syntaxhighlight lang="pascal" inline>{$openStrings}</syntaxhighlight> or <syntaxhighlight lang="pascal" inline>{$P}</syntaxhighlight>]] determines, whether all routine parameters of type <syntaxhighlight lang="pascal" inline>string</syntaxhighlight> are considered to be open string parameters; this parameter only has effect for short strings, not for <syntaxhighlight lang="pascal" inline>ANSIString</syntaxhighlight>s.
 
* [[$openStrings|<syntaxhighlight lang="pascal" inline>{$openStrings}</syntaxhighlight> or <syntaxhighlight lang="pascal" inline>{$P}</syntaxhighlight>]] determines, whether all routine parameters of type <syntaxhighlight lang="pascal" inline>string</syntaxhighlight> are considered to be open string parameters; this parameter only has effect for short strings, not for <syntaxhighlight lang="pascal" inline>ANSIString</syntaxhighlight>s.
 
* [[$varPropSetter|<syntaxhighlight lang="pascal" inline>{$varPropSetter}</syntaxhighlight>]]
 
* [[$varPropSetter|<syntaxhighlight lang="pascal" inline>{$varPropSetter}</syntaxhighlight>]]
  
== code generation ==
+
== Code generation ==
 +
 
 
* [[$codePage|<syntaxhighlight lang="pascal" inline>{$codePage}</syntaxhighlight>]] determines which code page is used by the program
 
* [[$codePage|<syntaxhighlight lang="pascal" inline>{$codePage}</syntaxhighlight>]] determines which code page is used by the program
 
* [[$E|<syntaxhighlight lang="pascal" inline>{$E}</syntaxhighlight>]] emulate co-processor
 
* [[$E|<syntaxhighlight lang="pascal" inline>{$E}</syntaxhighlight>]] emulate co-processor
Line 27: Line 32:
 
* [[$sysCalls|<syntaxhighlight lang="pascal" inline>{$sysCalls}</syntaxhighlight>]] determines system call calling conventions on Amiga/MorphOS
 
* [[$sysCalls|<syntaxhighlight lang="pascal" inline>{$sysCalls}</syntaxhighlight>]] determines system call calling conventions on Amiga/MorphOS
  
== data inclusion ==
+
== Data inclusion ==
 +
 
 
* [[$debugInfo|<syntaxhighlight lang="pascal" inline>{$debugInfo}</syntaxhighlight> or <syntaxhighlight lang="pascal" inline>{$D}</syntaxhighlight>]] inserts GNU debugging information into generated code
 
* [[$debugInfo|<syntaxhighlight lang="pascal" inline>{$debugInfo}</syntaxhighlight> or <syntaxhighlight lang="pascal" inline>{$D}</syntaxhighlight>]] inserts GNU debugging information into generated code
 
* [[$referenceInfo|<syntaxhighlight lang="pascal" inline>{$referenceInfo}</syntaxhighlight> or <syntaxhighlight lang="pascal" inline>{$Y}</syntaxhighlight>]] creates Delphi-compatible browser information (not yet fully supported)
 
* [[$referenceInfo|<syntaxhighlight lang="pascal" inline>{$referenceInfo}</syntaxhighlight> or <syntaxhighlight lang="pascal" inline>{$Y}</syntaxhighlight>]] creates Delphi-compatible browser information (not yet fully supported)
  
== paths ==
+
== Paths ==
 +
 
 
* [[$framework|<syntaxhighlight lang="pascal" inline>{$frameworkPath}</syntaxhighlight>]] (on Darwin)
 
* [[$framework|<syntaxhighlight lang="pascal" inline>{$frameworkPath}</syntaxhighlight>]] (on Darwin)
 
* [[$include|<syntaxhighlight lang="pascal" inline>{$includePath}</syntaxhighlight>]] determines path for include files
 
* [[$include|<syntaxhighlight lang="pascal" inline>{$includePath}</syntaxhighlight>]] determines path for include files
Line 38: Line 45:
 
* [[FPC paths|<syntaxhighlight lang="pascal" inline>{$unitPath}</syntaxhighlight>]] determines search path for units
 
* [[FPC paths|<syntaxhighlight lang="pascal" inline>{$unitPath}</syntaxhighlight>]] determines search path for units
  
== target-dependent ==
+
== Target-dependent ==
 +
 
 
=== Novell NetWare only ===
 
=== Novell NetWare only ===
 +
 
* [[$copyright|<syntaxhighlight lang="pascal" inline>{$copyright}</syntaxhighlight>]] inserts copyright information
 
* [[$copyright|<syntaxhighlight lang="pascal" inline>{$copyright}</syntaxhighlight>]] inserts copyright information
 
* [[$screenName|<syntaxhighlight lang="pascal" inline>{$screenName}</syntaxhighlight>]] determines screen name of application
 
* [[$screenName|<syntaxhighlight lang="pascal" inline>{$screenName}</syntaxhighlight>]] determines screen name of application
Line 45: Line 54:
  
 
=== Palm OS and Garnet OS only ===
 
=== Palm OS and Garnet OS only ===
 +
 
* <syntaxhighlight lang="pascal" inline>{$appID}</syntaxhighlight> defines four-character application identifier
 
* <syntaxhighlight lang="pascal" inline>{$appID}</syntaxhighlight> defines four-character application identifier
 
* <syntaxhighlight lang="pascal" inline>{$appName}</syntaxhighlight> determines the name of the application
 
* <syntaxhighlight lang="pascal" inline>{$appName}</syntaxhighlight> determines the name of the application
  
 
=== Windows-based systems ===
 
=== Windows-based systems ===
 +
 
* [[$imageBase|<syntaxhighlight lang="pascal" inline>{$imageBase}</syntaxhighlight>]] specifies DLL image base location
 
* [[$imageBase|<syntaxhighlight lang="pascal" inline>{$imageBase}</syntaxhighlight>]] specifies DLL image base location
 
* <syntaxhighlight lang="pascal" inline>{$minStackSize}</syntaxhighlight>
 
* <syntaxhighlight lang="pascal" inline>{$minStackSize}</syntaxhighlight>
 
* <syntaxhighlight lang="pascal" inline>{$maxStackSize}</syntaxhighlight>
 
* <syntaxhighlight lang="pascal" inline>{$maxStackSize}</syntaxhighlight>
 
 
* <syntaxhighlight lang="pascal" inline>{$setPEFlags}</syntaxhighlight>
 
* <syntaxhighlight lang="pascal" inline>{$setPEFlags}</syntaxhighlight>
 
* <syntaxhighlight lang="pascal" inline>{$version}</syntaxhighlight> defines version number of a DLL
 
* <syntaxhighlight lang="pascal" inline>{$version}</syntaxhighlight> defines version number of a DLL
  
=== miscellaneous ===
+
=== Miscellaneous ===
 +
 
 
* [[$appType|<syntaxhighlight lang="pascal" inline>{$appType}</syntaxhighlight>]] determines the program type
 
* [[$appType|<syntaxhighlight lang="pascal" inline>{$appType}</syntaxhighlight>]] determines the program type
  
== compile-time data ==
+
== Compile-time data ==
 +
 
 
* [[$profile|<syntaxhighlight lang="pascal" inline>{$profile}</syntaxhighlight>]] enables generation of profile code
 
* [[$profile|<syntaxhighlight lang="pascal" inline>{$profile}</syntaxhighlight>]] enables generation of profile code
  
== ignored ==
+
== Ignored ==
 +
 
 
* <syntaxhighlight lang="pascal" inline>{$description}</syntaxhighlight>: introduced for compatibility and as of FPC 3.0.4 ignored
 
* <syntaxhighlight lang="pascal" inline>{$description}</syntaxhighlight>: introduced for compatibility and as of FPC 3.0.4 ignored
 
* <syntaxhighlight lang="pascal" inline>{$G}</syntaxhighlight> would generate 80286 code with [[Turbo  Pascal|TP]]
 
* <syntaxhighlight lang="pascal" inline>{$G}</syntaxhighlight> would generate 80286 code with [[Turbo  Pascal|TP]]
Line 70: Line 83:
 
* <syntaxhighlight lang="pascal" inline>{$weakPackageUnit}</syntaxhighlight>
 
* <syntaxhighlight lang="pascal" inline>{$weakPackageUnit}</syntaxhighlight>
  
== see also ==
+
== See also ==
 +
 
 +
* [[Pascal basics]]
 
* [https://www.freepascal.org/docs-html/prog/progse3.html § “global directives” in the ''Free Pascal programmer’s guide'']
 
* [https://www.freepascal.org/docs-html/prog/progse3.html § “global directives” in the ''Free Pascal programmer’s guide'']
 
   
 
   
 
{{Directives, Defines and Conditionals}}
 
{{Directives, Defines and Conditionals}}

Latest revision as of 14:23, 19 February 2021

Deutsch (de) English (en) français (fr) русский (ru)

Free Pascal supports compiler directives in the source file. Basically the same directives as in Turbo Pascal, Delphi and Apple Pascal (Mac OS) pascal compilers are supported. Some are recognized for compatibility only, and have no effect.

Syntax

General:

Specific:

Code generation

Data inclusion

Paths

Target-dependent

Novell NetWare only

Palm OS and Garnet OS only

  • {$appID} defines four-character application identifier
  • {$appName} determines the name of the application

Windows-based systems

  • {$imageBase} specifies DLL image base location
  • {$minStackSize}
  • {$maxStackSize}
  • {$setPEFlags}
  • {$version} defines version number of a DLL

Miscellaneous

Compile-time data

Ignored

  • {$description}: introduced for compatibility and as of FPC 3.0.4 ignored
  • {$G} would generate 80286 code with TP
  • {$localSymbols} or {$L}
  • {$N} (numeric processing)
  • {$O} enabled level 2 optimizations. It is not recognized anymore since FPC 2.0.0. Use {$optimization} instead.
  • {$weakPackageUnit}

See also

Directives, definitions and conditionals definitions
global compiler directives • local compiler directives

Conditional Compiler Options • Conditional compilation • Macros and Conditionals • Platform defines
$IF