Difference between revisions of "global compiler directives"

From Lazarus wiki
Jump to navigationJump to search
m
(→‎Syntax: reword short description to be more accurate)
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{{global compiler directives}}
 
{{global compiler directives}}
  
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.
+
Free Pascal supports [[Compiler directive|compiler directives]] in the [[Source code|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.
  
__TOC__
+
== Syntax ==
==Gobal Compiler Directives==
 
*[[sGlobalApptype|$APPTYPE]] determines the program type.
 
*[[sGlobalCalling|$CALLING]] determines the calling convention of internal and external procedures and functions.
 
*[[sGlobalCodepage|$code page]] determines which code page is used by the program.
 
*[[sGlobalDebuginfo|$D oder $DEBUGINFO]] insert GNU debugging information into generated code.
 
*[[sGlobalDescription|$DESCRIPTION]] currently ignored by compiler.
 
*[[sGlobalE|$E]] emulate coprocessor.
 
*[[sGlobalG|$G]] currently ignored by compiler (reserved for generation of 80286 code).
 
*[[sGlobalIncludepath|$INCLUDEPATH]] determines path for include files.
 
*[[sGlobalInterfaces|$INTERFACES]] determines software interface for compiler
 
*[[sGlobalLocalsymbols|$LOCALSYMBOLS]] currently ignored by compiler.
 
*[[sGlobalLibrarypath|$LIBRARYPATH]] determines path to library files.
 
*[[sGlobalMemory|$MEMORY]] determines size of memory to use.
 
*[[sGlobalMode|$MODE]] determines compatibility mode of compiler.
 
*[[sGlobalModeswitch|$MODESWITCH]] enables selection of certain functions.
 
*[[sGlobalN|$N]] currently ignored by compiler.
 
*[[sGlobalO|$O]] currently ignored by compiler.
 
*[[sGlobalObjectpath|$OBJECTPATH]] defines path to object files
 
*[[sGlobalOpenstrings|$P or $OPENSTRINGS]] determines parameters of procedures and functions to be ShortStrings
 
*[[sGlobalPascalmainname|$PASCALMAINNAME]] determines name of entry point.
 
*[[sGlobalPic|$PIC]] enables PIC code generation.
 
*[[sGlobalProfile|$PROFILE]] enables generation of profile code
 
*[[sGlobalS|$S]] creates code to check for stack overflow.
 
*[[sGlobalSmartlink|$SMARTLINK]] determines smart linking
 
*[[sGlobalThreading|$THREADING]] currently ignored by compiler.
 
*[[sGlobalUnitpath|$UNITPATH]] determines search path for units
 
*[[sGlobalVersion|$VERSION]] defines version number of DLL
 
*[[sGlobalWeakpackageunit|$WEAKPACKAGEUNIT]] currently ignored by compiler
 
*[[sGlobalExtendedsyntax|$X or $EXTENDEDSYNTAX]] enables calling of functions like procedures
 
*[[sGlobalReferenceinfo|$Y or $REFERENCEINFO]] creates Delphi-compatible browser info.
 
  
==Global directives for Novell NetWare only==
+
General:
*[[sGlobalCopyright|$COPYRIGHT]] inserts copyright information
 
*[[sGlobalScreenname|$SCREENNAME]] determines screen name for application
 
*[[sGlobalThreadname|$THREADNAME]] defines name of thread
 
  
==Global directives for Palm OS and Garnet OS only==
+
* [[$mode|<syntaxhighlight lang="pascal" inline>{$mode}</syntaxhighlight>]] selects the compiler mode
*[[sGlobalAppID|$APPID id]] defines four-character AppID
+
* [[$modeSwitch|<syntaxhighlight lang="pascal" inline>{$modeSwitch}</syntaxhighlight>]] turns on or off specific mode features
*[[sGlobalAppName|$APPName]] determines name of application.
 
  
{{Template:Directives, Defines and Conditionals}}
+
Specific:
 +
 
 +
* [[$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.
 +
* [[$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 ==
 +
 
 +
=== Novell NetWare only ===
 +
 
 +
* [[$copyright|<syntaxhighlight lang="pascal" inline>{$copyright}</syntaxhighlight>]] inserts copyright information
 +
* [[$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 ===
 +
 
 +
* <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 ===
 +
 
 +
* [[$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
 +
 
 +
== 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>{$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>
 +
 
 +
== See also ==
 +
 
 +
* [[Pascal basics]]
 +
* [https://www.freepascal.org/docs-html/prog/progse3.html § “global directives” in the ''Free Pascal programmer’s guide'']
 +
 +
{{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