Difference between revisions of "global compiler directives"

From Lazarus wiki
Jump to navigationJump to search
(review, brand new! now with a 100% more structure. awesome!)
(→‎Syntax: reword short description to be more accurate)
 
(5 intermediate revisions by 2 users 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:
 
* [[$mode|<syntaxhighlight lang="pascal" enclose="none">{$mode}</syntaxhighlight>]] selects the compiler mode
 
* [[$modeSwitch|<syntaxhighlight lang="pascal" enclose="none">{$modeSwitch}</syntaxhighlight>]] turns on or off specific mode features
 
specific:
 
* [[$extendedSyntax|<syntaxhighlight lang="pascal" enclose="none">{$extendedSyntax}</syntaxhighlight>]] allows using functions as if they were procedures
 
* [[$pointerMath|<syntaxhighlight lang="pascal" enclose="none">{$pointerMath}</syntaxhighlight>]] allows arithmetic operations with pointers
 
* [[$openStrings|<syntaxhighlight lang="pascal" enclose="none">{$openStrings}</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">{$P}</syntaxhighlight>]] determines, whether all routine parameters of type <syntaxhighlight lang="pascal" enclose="none">string</syntaxhighlight> are considered to be open string parameters; this parameter only has effect for short strings, not for <syntaxhighlight lang="pascal" enclose="none">ANSIString</syntaxhighlight>s.
 
* [[$varPropSetter|<syntaxhighlight lang="pascal" enclose="none">{$varPropSetter}</syntaxhighlight>]]
 
  
== code generation ==
+
General:
* [[$codePage|<syntaxhighlight lang="pascal" enclose="none">{$codePage}</syntaxhighlight>]] determines which code page is used by the program
 
* [[$E|<syntaxhighlight lang="pascal" enclose="none">{$E}</syntaxhighlight>]] emulate co-processor
 
* [[$S|<syntaxhighlight lang="pascal" enclose="none">{$S}</syntaxhighlight>]] creates code to check for stack overflows
 
* [[$memory|<syntaxhighlight lang="pascal" enclose="none">{$memory}</syntaxhighlight>]] determines size of memory to use
 
* [[$pascalMainName|<syntaxhighlight lang="pascal" enclose="none">{$PascalMainName}</syntaxhighlight>]] determines name of entry point
 
* [[$PIC|<syntaxhighlight lang="pascal" enclose="none">{$PIC}</syntaxhighlight>]] enables position independent code code generation
 
* [[$smartlink|<syntaxhighlight lang="pascal" enclose="none">{$smartlink}</syntaxhighlight>]] determines smartlinking
 
  
== data inclusion ==
+
* [[$mode|<syntaxhighlight lang="pascal" inline>{$mode}</syntaxhighlight>]] selects the compiler mode
* [[$debugInfo|<syntaxhighlight lang="pascal" enclose="none">{$debugInfo}</syntaxhighlight>]] inserts GNU debugging information into generated code
+
* [[$modeSwitch|<syntaxhighlight lang="pascal" inline>{$modeSwitch}</syntaxhighlight>]] turns on or off specific mode features
* [[$referenceInfo|<syntaxhighlight lang="pascal" enclose="none">{$referenceInfo}</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">{$Y}</syntaxhighlight>]] creates Delphi-compatible browser information (not yet fully supported)
 
  
== paths ==
+
Specific:
* [[$framework|<syntaxhighlight lang="pascal" enclose="none">{$frameworkPath}</syntaxhighlight>]] (on Darwin)
+
 
* [[$include|<syntaxhighlight lang="pascal" enclose="none">{$includePath}</syntaxhighlight>]] determines path for include files
+
* [[$extendedSyntax|<syntaxhighlight lang="pascal" inline>{$extendedSyntax}</syntaxhighlight>]] enables multiple syntax extensions
* [[FPC paths|<syntaxhighlight lang="pascal" enclose="none">{$libraryPath}</syntaxhighlight>]] determines the path to library files
+
* [[$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]])
* [[FPC paths|<syntaxhighlight lang="pascal" enclose="none">{$objectPath}</syntaxhighlight>]] defines the path to search for object files at
+
* [[$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.
* [[FPC paths|<syntaxhighlight lang="pascal" enclose="none">{$unitPath}</syntaxhighlight>]] determines search path for units
+
* [[$varPropSetter|<syntaxhighlight lang="pascal" inline>{$varPropSetter}</syntaxhighlight>]]
 +
 
 +
== Code generation ==
 +
 
 +
* [[$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
 +
* [[$extension|<syntaxhighlight lang="pascal" inline>{$extension}</syntaxhighlight>]] determines file name suffix of the generated [[Executable program|executable]]
 +
* [[$libPrefix and $libSuffix|<syntaxhighlight lang="pascal" inline>{$libPrefix}</syntaxhighlight>]] determines file name prefix a generated library
 +
* [[$libPrefix and $libSuffix|<syntaxhighlight lang="pascal" inline>{$libSuffix}</syntaxhighlight>]] determines file name suffix a generated library
 +
* [[$memory|<syntaxhighlight lang="pascal" inline>{$memory}</syntaxhighlight>]] determines size of memory to use
 +
* [[$pascalMainName|<syntaxhighlight lang="pascal" inline>{$PascalMainName}</syntaxhighlight>]] determines name of entry point
 +
* [[$PIC|<syntaxhighlight lang="pascal" inline>{$PIC}</syntaxhighlight>]] enables position independent code code generation
 +
* [[$smartlink|<syntaxhighlight lang="pascal" inline>{$smartlink}</syntaxhighlight>]] determines smartlinking
 +
* [[$sysCalls|<syntaxhighlight lang="pascal" inline>{$sysCalls}</syntaxhighlight>]] determines system call calling conventions on Amiga/MorphOS
 +
 
 +
== Data inclusion ==
 +
 
 +
* [[$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)
 +
 
 +
== Paths ==
 +
 
 +
* [[$framework|<syntaxhighlight lang="pascal" inline>{$frameworkPath}</syntaxhighlight>]] (on Darwin)
 +
* [[$include|<syntaxhighlight lang="pascal" inline>{$includePath}</syntaxhighlight>]] determines path for include files
 +
* [[FPC paths|<syntaxhighlight lang="pascal" inline>{$libraryPath}</syntaxhighlight>]] determines the path to library files
 +
* [[FPC paths|<syntaxhighlight lang="pascal" inline>{$objectPath}</syntaxhighlight>]] defines the path to search for object files at
 +
* [[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" enclose="none">{$copyright}</syntaxhighlight>]] inserts copyright information
+
 
* [[$screenName|<syntaxhighlight lang="pascal" enclose="none">{$screenName}</syntaxhighlight>]] determines screen name of application
+
* [[$copyright|<syntaxhighlight lang="pascal" inline>{$copyright}</syntaxhighlight>]] inserts copyright information
* [[$threadName|<syntaxhighlight lang="pascal" enclose="none">{$threadName}</syntaxhighlight>]] defines name of thread
+
* [[$screenName|<syntaxhighlight lang="pascal" inline>{$screenName}</syntaxhighlight>]] determines screen name of application
 +
* [[$threadName|<syntaxhighlight lang="pascal" inline>{$threadName}</syntaxhighlight>]] defines name of thread
  
 
=== Palm OS and Garnet OS only ===
 
=== Palm OS and Garnet OS only ===
* <syntaxhighlight lang="pascal" enclose="none">{$appID}</syntaxhighlight> defines four-character application identifier
+
 
* <syntaxhighlight lang="pascal" enclose="none">{$appName}</syntaxhighlight> determines the name of the application
+
* <syntaxhighlight lang="pascal" inline>{$appID}</syntaxhighlight> defines four-character application identifier
 +
* <syntaxhighlight lang="pascal" inline>{$appName}</syntaxhighlight> determines the name of the application
  
 
=== Windows-based systems ===
 
=== Windows-based systems ===
* [[$imageBase|<syntaxhighlight lang="pascal" enclose="none">{$imageBase}</syntaxhighlight>]] specifies DLL image base location
 
* <syntaxhighlight lang="pascal" enclose="none">{$minStackSize}</syntaxhighlight>
 
* <syntaxhighlight lang="pascal" enclose="none">{$maxStackSize}</syntaxhighlight>
 
  
* <syntaxhighlight lang="pascal" enclose="none">{$version}</syntaxhighlight> defines version number of a DLL
+
* [[$imageBase|<syntaxhighlight lang="pascal" inline>{$imageBase}</syntaxhighlight>]] specifies DLL image base location
 +
* <syntaxhighlight lang="pascal" inline>{$minStackSize}</syntaxhighlight>
 +
* <syntaxhighlight lang="pascal" inline>{$maxStackSize}</syntaxhighlight>
 +
* <syntaxhighlight lang="pascal" inline>{$setPEFlags}</syntaxhighlight>
 +
* <syntaxhighlight lang="pascal" inline>{$version}</syntaxhighlight> defines version number of a DLL
 +
 
 +
=== Miscellaneous ===
 +
 
 +
* [[$appType|<syntaxhighlight lang="pascal" inline>{$appType}</syntaxhighlight>]] determines the program type
 +
 
 +
== Compile-time data ==
 +
 
 +
* [[$profile|<syntaxhighlight lang="pascal" inline>{$profile}</syntaxhighlight>]] enables generation of profile code
  
=== miscellaneous ===
+
== Ignored ==
* [[$appType|<syntaxhighlight lang="pascal" enclose="none">{$appType}</syntaxhighlight>]] determines the program type
 
  
== compile-time data ==
+
* <syntaxhighlight lang="pascal" inline>{$description}</syntaxhighlight>: introduced for compatibility and as of FPC 3.0.4 ignored
* [[$profile|<syntaxhighlight lang="pascal" enclose="none">{$profile}</syntaxhighlight>]] enables generation of profile code
+
* <syntaxhighlight lang="pascal" inline>{$G}</syntaxhighlight> would generate 80286 code with [[Turbo  Pascal|TP]]
 +
* <syntaxhighlight lang="pascal" inline>{$localSymbols}</syntaxhighlight> or <syntaxhighlight lang="pascal" inline>{$L}</syntaxhighlight>
 +
* <syntaxhighlight lang="pascal" inline>{$N}</syntaxhighlight> (numeric processing)
 +
* <syntaxhighlight lang="pascal" inline>{$O}</syntaxhighlight> enabled level 2 optimizations. It is not recognized anymore since FPC 2.0.0. Use [[$optimization|<syntaxhighlight lang="pascal" inline>{$optimization}</syntaxhighlight>]] instead.
 +
* <syntaxhighlight lang="pascal" inline>{$weakPackageUnit}</syntaxhighlight>
  
== ignored ==
+
== See also ==
* <syntaxhighlight lang="pascal" enclose="none">{$description}</syntaxhighlight>: introduced for compatibility and as of FPC 3.0.4 ignored
 
* <syntaxhighlight lang="pascal" enclose="none">{$G}</syntaxhighlight> would generate 80286 code with [[Turbo  Pascal|TP]]
 
* <syntaxhighlight lang="pascal" enclose="none">{$localSymbols}</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">{$L}</syntaxhighlight>
 
* <syntaxhighlight lang="pascal" enclose="none">{$N}</syntaxhighlight> (numeric processing)
 
* <syntaxhighlight lang="pascal" enclose="none">{$O}</syntaxhighlight> enabled level 2 optimizations. It is not recognized anymore since FPC 2.0.0. Use [[$optimization|<syntaxhighlight lang="pascal" enclose="none">{$optimization}</syntaxhighlight>]] instead.
 
* <syntaxhighlight lang="pascal" enclose="none">{$weakPackageUnit}</syntaxhighlight>
 
  
== 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