Difference between revisions of "local compiler directives"

From Free Pascal wiki
(code generation: cf. Special:Diff/126858)
m (substitute syntaxhighlight legacy)
Line 4: Line 4:
  
 
== syntax ==
 
== syntax ==
* <syntaxhighlight lang="pascal" enclose="none">{$cOperators}</syntaxhighlight> enables usage of [[Operator|operators]] similar to conventions of in the [[Pascal for C users|C]] language.
+
* <syntaxhighlight lang="pascal" inline>{$cOperators}</syntaxhighlight> enables usage of [[Operator|operators]] similar to conventions of in the [[Pascal for C users|C]] language.
* <syntaxhighlight lang="pascal" enclose="none">{$goto}</syntaxhighlight> enables [[Goto|<syntaxhighlight lang="pascal" enclose="none">goto</syntaxhighlight>]] and [[Label|<syntaxhighlight lang="pascal" enclose="none">label</syntaxhighlight>]].
+
* <syntaxhighlight lang="pascal" inline>{$goto}</syntaxhighlight> enables [[Goto|<syntaxhighlight lang="pascal" inline>goto</syntaxhighlight>]] and [[Label|<syntaxhighlight lang="pascal" inline>label</syntaxhighlight>]].
* <syntaxhighlight lang="pascal" enclose="none">{$inline}</syntaxhighlight> allows the [[inline|<syntaxhighlight lang="pascal" enclose="none">inline</syntaxhighlight> modifier]].
+
* <syntaxhighlight lang="pascal" inline>{$inline}</syntaxhighlight> allows the [[inline|<syntaxhighlight lang="pascal" inline>inline</syntaxhighlight> modifier]].
* [[$longStrings|<syntaxhighlight lang="pascal" enclose="none">{$longStrings}</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">{$H}</syntaxhighlight>]] determines the data type referenced by the reserved word [[String|<syntaxhighlight lang="pascal" enclose="none">string</syntaxhighlight>]].
+
* [[$longStrings|<syntaxhighlight lang="pascal" inline>{$longStrings}</syntaxhighlight> or <syntaxhighlight lang="pascal" inline>{$H}</syntaxhighlight>]] determines the data type referenced by the reserved word [[String|<syntaxhighlight lang="pascal" inline>string</syntaxhighlight>]].
* <syntaxhighlight lang="pascal" enclose="none">{$macro}</syntaxhighlight> enables usage of [[Macros|macros]].
+
* <syntaxhighlight lang="pascal" inline>{$macro}</syntaxhighlight> enables usage of [[Macros|macros]].
* [[$scopedEnums|<syntaxhighlight lang="pascal" enclose="none">{$scopedEnums}</syntaxhighlight>]] whether enumeration type members have to be referred to by the data types name as a scope. (since [[FPC New Features 2.6.0#Scoped enumerations|FPC 2.6.0]])
+
* [[$scopedEnums|<syntaxhighlight lang="pascal" inline>{$scopedEnums}</syntaxhighlight>]] whether enumeration type members have to be referred to by the data types name as a scope. (since [[FPC New Features 2.6.0#Scoped enumerations|FPC 2.6.0]])
* [[$static|<syntaxhighlight lang="pascal" enclose="none">{$static}</syntaxhighlight>]] enable usage of the reserved word <syntaxhighlight lang="delphi" enclose="none">static</syntaxhighlight> (until [[User Changes 2.6.0#The Static modifier is now always enabled|FPC 2.6.0]]).
+
* [[$static|<syntaxhighlight lang="pascal" inline>{$static}</syntaxhighlight>]] enable usage of the reserved word <syntaxhighlight lang="delphi" inline>static</syntaxhighlight> (until [[User Changes 2.6.0#The Static modifier is now always enabled|FPC 2.6.0]]).
* [[$typedAddress|<syntaxhighlight lang="pascal" enclose="none">{$typedAddress}</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">{$T}</syntaxhighlight>]] determines, if the address operator [[@|<syntaxhighlight lang="pascal" enclose="none">@</syntaxhighlight>]] results in a typed or untyped pointer.
+
* [[$typedAddress|<syntaxhighlight lang="pascal" inline>{$typedAddress}</syntaxhighlight> or <syntaxhighlight lang="pascal" inline>{$T}</syntaxhighlight>]] determines, if the address operator [[@|<syntaxhighlight lang="pascal" inline>@</syntaxhighlight>]] results in a typed or untyped pointer.
* [[$varStringChecks|<syntaxhighlight lang="pascal" enclose="none">{$varStringChecks}</syntaxhighlight> and <syntaxhighlight lang="pascal" enclose="none">{$V}</syntaxhighlight>]] enables strict checking of assignment compatibility of string variables.
+
* [[$varStringChecks|<syntaxhighlight lang="pascal" inline>{$varStringChecks}</syntaxhighlight> and <syntaxhighlight lang="pascal" inline>{$V}</syntaxhighlight>]] enables strict checking of assignment compatibility of string variables.
* [[$writableConst|<syntaxhighlight lang="pascal" enclose="none">{$writableConst}</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">{$J}</syntaxhighlight>]] enables assignment of values to typed [[Constant|constants]] during [[runtime|run-time]].
+
* [[$writableConst|<syntaxhighlight lang="pascal" inline>{$writableConst}</syntaxhighlight> or <syntaxhighlight lang="pascal" inline>{$J}</syntaxhighlight>]] enables assignment of values to typed [[Constant|constants]] during [[runtime|run-time]].
  
 
== data layout ==
 
== data layout ==
* [[$align|<syntaxhighlight lang="pascal" enclose="none">{$align}</syntaxhighlight> and <syntaxhighlight lang="pascal" enclose="none">{$A}</syntaxhighlight>]] determine the alignment of data in records
+
* [[$align|<syntaxhighlight lang="pascal" inline>{$align}</syntaxhighlight> and <syntaxhighlight lang="pascal" inline>{$A}</syntaxhighlight>]] determine the alignment of data in records
* [[$bitpacking|<syntaxhighlight lang="pascal" enclose="none">{$bitpacking}</syntaxhighlight>]] determines, whether <syntaxhighlight lang="pascal" enclose="none">packed</syntaxhighlight> is interpreted as <syntaxhighlight lang="pascal" enclose="none">bitpacked</syntaxhighlight>.
+
* [[$bitpacking|<syntaxhighlight lang="pascal" inline>{$bitpacking}</syntaxhighlight>]] determines, whether <syntaxhighlight lang="pascal" inline>packed</syntaxhighlight> is interpreted as <syntaxhighlight lang="pascal" inline>bitpacked</syntaxhighlight>.
* [[$codeAlign|<syntaxhighlight lang="pascal" enclose="none">{$codeAlign}</syntaxhighlight>]] determines the code-alignment in memory.
+
* [[$codeAlign|<syntaxhighlight lang="pascal" inline>{$codeAlign}</syntaxhighlight>]] determines the code-alignment in memory.
* <syntaxhighlight lang="pascal" enclose="none">{$minEnumSize}</syntaxhighlight> recognized for Delphi-compatibility and has the same effect as the <syntaxhighlight lang="pascal" enclose="none">{$packEnum}</syntaxhighlight> directive.
+
* <syntaxhighlight lang="pascal" inline>{$minEnumSize}</syntaxhighlight> recognized for Delphi-compatibility and has the same effect as the <syntaxhighlight lang="pascal" inline>{$packEnum}</syntaxhighlight> directive.
* [[$minFPConstPrec|<syntaxhighlight lang="pascal" enclose="none">{$minFPConstPrec}</syntaxhighlight>]] sets the minimum accuracy floating-point constants are stored at.
+
* [[$minFPConstPrec|<syntaxhighlight lang="pascal" inline>{$minFPConstPrec}</syntaxhighlight>]] sets the minimum accuracy floating-point constants are stored at.
* [[$packEnum|<syntaxhighlight lang="pascal" enclose="none">{$packEnum}</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">{$Z}</syntaxhighlight>]] enables packing of enumeration types.
+
* [[$packEnum|<syntaxhighlight lang="pascal" inline>{$packEnum}</syntaxhighlight> or <syntaxhighlight lang="pascal" inline>{$Z}</syntaxhighlight>]] enables packing of enumeration types.
* [[$packRecords|<syntaxhighlight lang="pascal" enclose="none">{$packRecords}</syntaxhighlight>]] determines alignment of [[Record|records]] in memory.
+
* [[$packRecords|<syntaxhighlight lang="pascal" inline>{$packRecords}</syntaxhighlight>]] determines alignment of [[Record|records]] in memory.
* [[$packSet|<syntaxhighlight lang="pascal" enclose="none">{$packSet}</syntaxhighlight>]] determines packing of [[Set|sets]].
+
* [[$packSet|<syntaxhighlight lang="pascal" inline>{$packSet}</syntaxhighlight>]] determines packing of [[Set|sets]].
  
 
== code generation ==
 
== code generation ==
* [[$boolEval|<syntaxhighlight lang="pascal" enclose="none">{$boolEval}</syntaxhighlight> and <syntaxhighlight lang="pascal" enclose="none">{$B}</syntaxhighlight>]] controls short-cut evaluation of Boolean expressions
+
* [[$boolEval|<syntaxhighlight lang="pascal" inline>{$boolEval}</syntaxhighlight> and <syntaxhighlight lang="pascal" inline>{$B}</syntaxhighlight>]] controls short-cut evaluation of Boolean expressions
* <syntaxhighlight lang="pascal" enclose="none">{$assertions}</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">{$C}</syntaxhighlight> control, whether [[assert|<syntaxhighlight lang="pascal" enclose="none">assert</syntaxhighlight> statements]] are compiled into the [[Executable program|executable program]]
+
* <syntaxhighlight lang="pascal" inline>{$assertions}</syntaxhighlight> or <syntaxhighlight lang="pascal" inline>{$C}</syntaxhighlight> control, whether [[assert|<syntaxhighlight lang="pascal" inline>assert</syntaxhighlight> statements]] are compiled into the [[Executable program|executable program]]
* [[$calling|<syntaxhighlight lang="pascal" enclose="none">{$calling}</syntaxhighlight>]] determines the calling conventions for routines.
+
* [[$calling|<syntaxhighlight lang="pascal" inline>{$calling}</syntaxhighlight>]] determines the calling conventions for routines.
* [[$checkPointer|<syntaxhighlight lang="pascal" enclose="none">{$checkPointer}</syntaxhighlight>]] inserts checks ascertain validity of [[Pointer|pointers]].
+
* [[$checkPointer|<syntaxhighlight lang="pascal" inline>{$checkPointer}</syntaxhighlight>]] inserts checks ascertain validity of [[Pointer|pointers]].
* [[$FPUtype|<syntaxhighlight lang="pascal" enclose="none">{$FPUType}</syntaxhighlight>]] compiles according to FPU type.
+
* [[$FPUtype|<syntaxhighlight lang="pascal" inline>{$FPUType}</syntaxhighlight>]] compiles according to FPU type.
* [[$ieeeERRORS|<syntaxhighlight lang="pascal" enclose="none">{$ieeeErrors}</syntaxhighlight>]] turns on IEEE error checking for floating-point constants.
+
* [[$ieeeERRORS|<syntaxhighlight lang="pascal" inline>{$ieeeErrors}</syntaxhighlight>]] turns on IEEE error checking for floating-point constants.
* [[$implicitExceptions|<syntaxhighlight lang="pascal" enclose="none">{$implicitExceptions}</syntaxhighlight>]] controls insertion of implicit exceptions which aid prevention of memory leaks.
+
* [[$implicitExceptions|<syntaxhighlight lang="pascal" inline>{$implicitExceptions}</syntaxhighlight>]] controls insertion of implicit exceptions which aid prevention of memory leaks.
* [[$interfaces|<syntaxhighlight lang="pascal" enclose="none">{$interfacse}</syntaxhighlight>]]
+
* [[$interfaces|<syntaxhighlight lang="pascal" inline>{$interfacse}</syntaxhighlight>]]
* [[$IOChecks|<syntaxhighlight lang="pascal" enclose="none">{$IOChecks}</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">{$I}</syntaxhighlight>]] enables checks of input/output.
+
* [[$IOChecks|<syntaxhighlight lang="pascal" inline>{$IOChecks}</syntaxhighlight> or <syntaxhighlight lang="pascal" inline>{$I}</syntaxhighlight>]] enables checks of input/output.
* [[$objectChecks|<syntaxhighlight lang="pascal" enclose="none">{$objectChecks}</syntaxhighlight>]] inserts code ensuring [[Self|<syntaxhighlight lang="pascal" enclose="none">self</syntaxhighlight>]] is non-[[Nil|<syntaxhighlight lang="pascal" enclose="none">nil</syntaxhighlight>]]
+
* [[$objectChecks|<syntaxhighlight lang="pascal" inline>{$objectChecks}</syntaxhighlight>]] inserts code ensuring [[Self|<syntaxhighlight lang="pascal" inline>self</syntaxhighlight>]] is non-[[Nil|<syntaxhighlight lang="pascal" inline>nil</syntaxhighlight>]]
* [[$optimization|<syntaxhighlight lang="pascal" enclose="none">{$optimization}</syntaxhighlight>]] switches on certain optimizations.
+
* [[$optimization|<syntaxhighlight lang="pascal" inline>{$optimization}</syntaxhighlight>]] switches on certain optimizations.
* [[$overflowChecks|<syntaxhighlight lang="pascal" enclose="none">{$overflowChecks}</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">{$Q}</syntaxhighlight>]] determines if overflow checks are inserted after arithmetic operations. In <syntaxhighlight lang="pascal" enclose="none">{$mode MacPas}</syntaxhighlight> the directive <syntaxhighlight lang="pascal" enclose="none">{$OV}</syntaxhighlight> is available, too.
+
* [[$overflowChecks|<syntaxhighlight lang="pascal" inline>{$overflowChecks}</syntaxhighlight> or <syntaxhighlight lang="pascal" inline>{$Q}</syntaxhighlight>]] determines if overflow checks are inserted after arithmetic operations. In <syntaxhighlight lang="pascal" inline>{$mode MacPas}</syntaxhighlight> the directive <syntaxhighlight lang="pascal" inline>{$OV}</syntaxhighlight> is available, too.
* [[$rangeChecks|<syntaxhighlight lang="pascal" enclose="none">{$rangeChecks}</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">{$R}</syntaxhighlight>]] determines insertion of code ensuring a value is within the permitted range.
+
* [[$rangeChecks|<syntaxhighlight lang="pascal" inline>{$rangeChecks}</syntaxhighlight> or <syntaxhighlight lang="pascal" inline>{$R}</syntaxhighlight>]] determines insertion of code ensuring a value is within the permitted range.
* [[$S|<syntaxhighlight lang="pascal" enclose="none">{$S}</syntaxhighlight>]] creates code to check for stack overflows
+
* [[$S|<syntaxhighlight lang="pascal" inline>{$S}</syntaxhighlight>]] creates code to check for stack overflows
* [[$stackFrames|<syntaxhighlight lang="pascal" enclose="none">{$stackFrames}</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">{$W}</syntaxhighlight>]] determines conditions for the creation of stack frames.
+
* [[$stackFrames|<syntaxhighlight lang="pascal" inline>{$stackFrames}</syntaxhighlight> or <syntaxhighlight lang="pascal" inline>{$W}</syntaxhighlight>]] determines conditions for the creation of stack frames.
  
 
== platform-specific ==
 
== platform-specific ==
 
=== for x86 processors only ===
 
=== for x86 processors only ===
* [[$asmMode|<syntaxhighlight lang="pascal" enclose="none">{$asmMode}</syntaxhighlight>]] determines the syntax the assembler reader expects. Previously, this has been the <syntaxhighlight lang="pascal" enclose="none">{$i386…}</syntaxhighlight> directives.
+
* [[$asmMode|<syntaxhighlight lang="pascal" inline>{$asmMode}</syntaxhighlight>]] determines the syntax the assembler reader expects. Previously, this has been the <syntaxhighlight lang="pascal" inline>{$i386…}</syntaxhighlight> directives.
* [[$MMX|<syntaxhighlight lang="pascal" enclose="none">{$MMX}</syntaxhighlight>]] enables optimizations for MMX processors.
+
* [[$MMX|<syntaxhighlight lang="pascal" inline>{$MMX}</syntaxhighlight>]] enables optimizations for MMX processors.
* [[$safeFPUExceptions|<syntaxhighlight lang="pascal" enclose="none">{$safeFPUExceptions}</syntaxhighlight>]], whether <syntaxhighlight lang="asm" enclose="none">fwait</syntaxhighlight> instructions are inserted
+
* [[$safeFPUExceptions|<syntaxhighlight lang="pascal" inline>{$safeFPUExceptions}</syntaxhighlight>]], whether <syntaxhighlight lang="asm" inline>fwait</syntaxhighlight> instructions are inserted
* [[$saturation|<syntaxhighlight lang="pascal" enclose="none">{$saturation}</syntaxhighlight>]] (in conjunction with <syntaxhighlight lang="pascal" enclose="none">{$MMX}</syntaxhighlight>) enables saturation operations.
+
* [[$saturation|<syntaxhighlight lang="pascal" inline>{$saturation}</syntaxhighlight>]] (in conjunction with <syntaxhighlight lang="pascal" inline>{$MMX}</syntaxhighlight>) enables saturation operations.
* [[$maxFPUregisters|<syntaxhighlight lang="pascal" enclose="none">{$maxFPUregisters}</syntaxhighlight>]] determines the maximum number of floating-points registers to use.
+
* [[$maxFPUregisters|<syntaxhighlight lang="pascal" inline>{$maxFPUregisters}</syntaxhighlight>]] determines the maximum number of floating-points registers to use.
  
 
=== other ===
 
=== other ===
* [[$linkFramework|<syntaxhighlight lang="pascal" enclose="none">{$linkFramework}</syntaxhighlight>]] inserts a framework. This directive is only available on Darwin-based operating systems.
+
* [[$linkFramework|<syntaxhighlight lang="pascal" inline>{$linkFramework}</syntaxhighlight>]] inserts a framework. This directive is only available on Darwin-based operating systems.
  
 
== data inclusion ==
 
== data inclusion ==
* [[$link|<syntaxhighlight lang="pascal" enclose="none">{$link}</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">{$L}</syntaxhighlight>]] inserts an object file during linking.
+
* [[$link|<syntaxhighlight lang="pascal" inline>{$link}</syntaxhighlight> or <syntaxhighlight lang="pascal" inline>{$L}</syntaxhighlight>]] inserts an object file during linking.
* [[$linkLib|<syntaxhighlight lang="pascal" enclose="none">{$linkLib}</syntaxhighlight>]] inserts a library during linking.
+
* [[$linkLib|<syntaxhighlight lang="pascal" inline>{$linkLib}</syntaxhighlight>]] inserts a library during linking.
* [[$typeInfo|<syntaxhighlight lang="pascal" enclose="none">{$typeInfo}</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">{$M}</syntaxhighlight>]] creates [[Runtime Type Information (RTTI)|run-time type information]].
+
* [[$typeInfo|<syntaxhighlight lang="pascal" inline>{$typeInfo}</syntaxhighlight> or <syntaxhighlight lang="pascal" inline>{$M}</syntaxhighlight>]] creates [[Runtime Type Information (RTTI)|run-time type information]].
* [[$output_format|<syntaxhighlight lang="pascal" enclose="none">{$output_format}</syntaxhighlight>]] determines output format of an object file.
+
* [[$output_format|<syntaxhighlight lang="pascal" inline>{$output_format}</syntaxhighlight>]] determines output format of an object file.
* [[$resource|<syntaxhighlight lang="pascal" enclose="none">{$resource}</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">{$R}</syntaxhighlight>]] inserts a resource file.
+
* [[$resource|<syntaxhighlight lang="pascal" inline>{$resource}</syntaxhighlight> or <syntaxhighlight lang="pascal" inline>{$R}</syntaxhighlight>]] inserts a resource file.
  
 
== compile-time context ==
 
== compile-time context ==
* [[$define|<syntaxhighlight lang="pascal" enclose="none">{$define}</syntaxhighlight>]] defines a symbol. In <syntaxhighlight lang="pascal" enclose="none">{$mode MacPas}</syntaxhighlight> the directive <syntaxhighlight lang="pascal" enclose="none">{$defineC}</syntaxhighlight> is considered, too.
+
* [[$define|<syntaxhighlight lang="pascal" inline>{$define}</syntaxhighlight>]] defines a symbol. In <syntaxhighlight lang="pascal" inline>{$mode MacPas}</syntaxhighlight> the directive <syntaxhighlight lang="pascal" inline>{$defineC}</syntaxhighlight> is considered, too.
* [[$include|<syntaxhighlight lang="pascal" enclose="none">{$include}</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">{$I}</syntaxhighlight>]] reads a file as source or includes certain compile-time/compiler information.
+
* [[$include|<syntaxhighlight lang="pascal" inline>{$include}</syntaxhighlight> or <syntaxhighlight lang="pascal" inline>{$I}</syntaxhighlight>]] reads a file as source or includes certain compile-time/compiler information.
* [[$push and $pop|<syntaxhighlight lang="pascal" enclose="none">{$push}</syntaxhighlight> and <syntaxhighlight lang="pascal" enclose="none">{$pop}</syntaxhighlight>]] store and restore the compiler settings.
+
* [[$push and $pop|<syntaxhighlight lang="pascal" inline>{$push}</syntaxhighlight> and <syntaxhighlight lang="pascal" inline>{$pop}</syntaxhighlight>]] store and restore the compiler settings.
* <syntaxhighlight lang="pascal" enclose="none">{$setC}</syntaxhighlight> sets a compile-time variable, if the current mode allows it.
+
* <syntaxhighlight lang="pascal" inline>{$setC}</syntaxhighlight> sets a compile-time variable, if the current mode allows it.
* <syntaxhighlight lang="pascal" enclose="none">{$undef}</syntaxhighlight> dismisses the definition of a previously defined symbol. In <syntaxhighlight lang="pascal" enclose="none">{$mode MacPas}</syntaxhighlight> the directive <syntaxhighlight lang="pascal" enclose="none">{$undefC}</syntaxhighlight> is recognized, too.
+
* <syntaxhighlight lang="pascal" inline>{$undef}</syntaxhighlight> dismisses the definition of a previously defined symbol. In <syntaxhighlight lang="pascal" inline>{$mode MacPas}</syntaxhighlight> the directive <syntaxhighlight lang="pascal" inline>{$undefC}</syntaxhighlight> is recognized, too.
  
 
== conditional compilation ==
 
== conditional compilation ==
 
[[Conditional compilation]] can be achieved via the directives
 
[[Conditional compilation]] can be achieved via the directives
* <syntaxhighlight lang="pascal" enclose="none">{$if}</syntaxhighlight>
+
* <syntaxhighlight lang="pascal" inline>{$if}</syntaxhighlight>
* <syntaxhighlight lang="pascal" enclose="none">{$else}</syntaxhighlight>
+
* <syntaxhighlight lang="pascal" inline>{$else}</syntaxhighlight>
* <syntaxhighlight lang="pascal" enclose="none">{$elseIf}</syntaxhighlight>
+
* <syntaxhighlight lang="pascal" inline>{$elseIf}</syntaxhighlight>
* <syntaxhighlight lang="pascal" enclose="none">{$endIf}</syntaxhighlight>
+
* <syntaxhighlight lang="pascal" inline>{$endIf}</syntaxhighlight>
* <syntaxhighlight lang="pascal" enclose="none">{$ifDef}</syntaxhighlight>
+
* <syntaxhighlight lang="pascal" inline>{$ifDef}</syntaxhighlight>
* <syntaxhighlight lang="pascal" enclose="none">{$ifNDef}</syntaxhighlight>
+
* <syntaxhighlight lang="pascal" inline>{$ifNDef}</syntaxhighlight>
* <syntaxhighlight lang="pascal" enclose="none">{$ifOpt}</syntaxhighlight>
+
* <syntaxhighlight lang="pascal" inline>{$ifOpt}</syntaxhighlight>
Additionally, in <syntaxhighlight lang="pascal" enclose="none">{$mode MacPas}</syntaxhighlight> the directives
+
Additionally, in <syntaxhighlight lang="pascal" inline>{$mode MacPas}</syntaxhighlight> the directives
* <syntaxhighlight lang="pascal" enclose="none">{$ifC}</syntaxhighlight>,
+
* <syntaxhighlight lang="pascal" inline>{$ifC}</syntaxhighlight>,
* <syntaxhighlight lang="pascal" enclose="none">{$elseC}</syntaxhighlight>,
+
* <syntaxhighlight lang="pascal" inline>{$elseC}</syntaxhighlight>,
* <syntaxhighlight lang="pascal" enclose="none">{$elIfC}</syntaxhighlight>, and
+
* <syntaxhighlight lang="pascal" inline>{$elIfC}</syntaxhighlight>, and
* <syntaxhighlight lang="pascal" enclose="none">{$endC}</syntaxhighlight>
+
* <syntaxhighlight lang="pascal" inline>{$endC}</syntaxhighlight>
 
are allowed, too.
 
are allowed, too.
  
 
== compile-time behavior ==
 
== compile-time behavior ==
With <syntaxhighlight lang="pascal" enclose="none">{$wait}</syntaxhighlight>, the compiler waits till the user hits ↵ Enter, and then resumes compilation.
+
With <syntaxhighlight lang="pascal" inline>{$wait}</syntaxhighlight>, the compiler waits till the user hits ↵ Enter, and then resumes compilation.
  
 
Self-defined messages can be triggered with the directives:
 
Self-defined messages can be triggered with the directives:
* [[$message|<syntaxhighlight lang="pascal" enclose="none">{$message}</syntaxhighlight>]], and the shortcuts
+
* [[$message|<syntaxhighlight lang="pascal" inline>{$message}</syntaxhighlight>]], and the shortcuts
** <syntaxhighlight lang="pascal" enclose="none">{$stop}</syntaxhighlight>, which also aborts compilation
+
** <syntaxhighlight lang="pascal" inline>{$stop}</syntaxhighlight>, which also aborts compilation
** <syntaxhighlight lang="pascal" enclose="none">{$fatal}</syntaxhighlight>, which also aborts compilation
+
** <syntaxhighlight lang="pascal" inline>{$fatal}</syntaxhighlight>, which also aborts compilation
** <syntaxhighlight lang="pascal" enclose="none">{$error}</syntaxhighlight> (in [[Mode MacPas|<syntaxhighlight lang="pascal" enclose="none">{$mode MacPas}</syntaxhighlight>]] the directive <syntaxhighlight lang="pascal" enclose="none">{$errorC}</syntaxhighlight> is accepted, too)
+
** <syntaxhighlight lang="pascal" inline>{$error}</syntaxhighlight> (in [[Mode MacPas|<syntaxhighlight lang="pascal" inline>{$mode MacPas}</syntaxhighlight>]] the directive <syntaxhighlight lang="pascal" inline>{$errorC}</syntaxhighlight> is accepted, too)
** <syntaxhighlight lang="pascal" enclose="none">{$warning}</syntaxhighlight>
+
** <syntaxhighlight lang="pascal" inline>{$warning}</syntaxhighlight>
** <syntaxhighlight lang="pascal" enclose="none">{$hint}</syntaxhighlight>
+
** <syntaxhighlight lang="pascal" inline>{$hint}</syntaxhighlight>
** <syntaxhighlight lang="pascal" enclose="none">{$note}</syntaxhighlight>
+
** <syntaxhighlight lang="pascal" inline>{$note}</syntaxhighlight>
* <syntaxhighlight lang="pascal" enclose="none">{$info}</syntaxhighlight>
+
* <syntaxhighlight lang="pascal" inline>{$info}</syntaxhighlight>
  
 
Emission of messages can be controlled via the directives:
 
Emission of messages can be controlled via the directives:
* [[$warn|<syntaxhighlight lang="pascal" enclose="none">{$warn}</syntaxhighlight>]] for specific warnings, or
+
* [[$warn|<syntaxhighlight lang="pascal" inline>{$warn}</syntaxhighlight>]] for specific warnings, or
 
* all messages of one kind in one go:
 
* all messages of one kind in one go:
** <syntaxhighlight lang="pascal" enclose="none">{$warnings}</syntaxhighlight>
+
** <syntaxhighlight lang="pascal" inline>{$warnings}</syntaxhighlight>
** <syntaxhighlight lang="pascal" enclose="none">{$hints}</syntaxhighlight>
+
** <syntaxhighlight lang="pascal" inline>{$hints}</syntaxhighlight>
** <syntaxhighlight lang="pascal" enclose="none">{$notes}</syntaxhighlight>
+
** <syntaxhighlight lang="pascal" inline>{$notes}</syntaxhighlight>
  
 
== ignored ==
 
== ignored ==
 
Since [[FPC]] intends to be sort of compatible to some other compilers, some very common compiler directives stemming from the non-FPC-lands are recognized – not generating an illegal directive error – and ignored.
 
Since [[FPC]] intends to be sort of compatible to some other compilers, some very common compiler directives stemming from the non-FPC-lands are recognized – not generating an illegal directive error – and ignored.
 
Those are:
 
Those are:
* <syntaxhighlight lang="pascal" enclose="none">{$F}</syntaxhighlight> (far or near functions)
+
* <syntaxhighlight lang="pascal" inline>{$F}</syntaxhighlight> (far or near functions)
* <syntaxhighlight lang="pascal" enclose="none">{$extendedSym}</syntaxhighlight>
+
* <syntaxhighlight lang="pascal" inline>{$extendedSym}</syntaxhighlight>
* <syntaxhighlight lang="pascal" enclose="none">{$externalSym}</syntaxhighlight>
+
* <syntaxhighlight lang="pascal" inline>{$externalSym}</syntaxhighlight>
* <syntaxhighlight lang="pascal" enclose="none">{$hppEmit}</syntaxhighlight>
+
* <syntaxhighlight lang="pascal" inline>{$hppEmit}</syntaxhighlight>
* <syntaxhighlight lang="pascal" enclose="none">{$libExport}</syntaxhighlight>
+
* <syntaxhighlight lang="pascal" inline>{$libExport}</syntaxhighlight>
* <syntaxhighlight lang="pascal" enclose="none">{$noDefine}</syntaxhighlight>
+
* <syntaxhighlight lang="pascal" inline>{$noDefine}</syntaxhighlight>
* <syntaxhighlight lang="pascal" enclose="none">{$region}</syntaxhighlight> and <syntaxhighlight lang="pascal" enclose="none">{$endRegion}</syntaxhighlight>
+
* <syntaxhighlight lang="pascal" inline>{$region}</syntaxhighlight> and <syntaxhighlight lang="pascal" inline>{$endRegion}</syntaxhighlight>
* <syntaxhighlight lang="pascal" enclose="none">{$stringChecks}</syntaxhighlight> which in Delphi, this would control the generation of code that checks the sanity of string variables and arguments.
+
* <syntaxhighlight lang="pascal" inline>{$stringChecks}</syntaxhighlight> which in Delphi, this would control the generation of code that checks the sanity of string variables and arguments.
  
 
== see also ==
 
== see also ==

Revision as of 16:17, 4 September 2019

Deutsch (de) English (en) français (fr)

Local compiler directives may be used more than once in a Pascal source code file.

syntax

data layout

code generation

platform-specific

for x86 processors only

  • {$asmMode} determines the syntax the assembler reader expects. Previously, this has been the {$i386…} directives.
  • {$MMX} enables optimizations for MMX processors.
  • {$safeFPUExceptions}, whether fwait instructions are inserted
  • {$saturation} (in conjunction with {$MMX}) enables saturation operations.
  • {$maxFPUregisters} determines the maximum number of floating-points registers to use.

other

  • {$linkFramework} inserts a framework. This directive is only available on Darwin-based operating systems.

data inclusion

compile-time context

  • {$define} defines a symbol. In {$mode MacPas} the directive {$defineC} is considered, too.
  • {$include} or {$I} reads a file as source or includes certain compile-time/compiler information.
  • {$push} and {$pop} store and restore the compiler settings.
  • {$setC} sets a compile-time variable, if the current mode allows it.
  • {$undef} dismisses the definition of a previously defined symbol. In {$mode MacPas} the directive {$undefC} is recognized, too.

conditional compilation

Conditional compilation can be achieved via the directives

  • {$if}
  • {$else}
  • {$elseIf}
  • {$endIf}
  • {$ifDef}
  • {$ifNDef}
  • {$ifOpt}

Additionally, in {$mode MacPas} the directives

  • {$ifC},
  • {$elseC},
  • {$elIfC}, and
  • {$endC}

are allowed, too.

compile-time behavior

With {$wait}, the compiler waits till the user hits ↵ Enter, and then resumes compilation.

Self-defined messages can be triggered with the directives:

  • {$message}, and the shortcuts
    • {$stop}, which also aborts compilation
    • {$fatal}, which also aborts compilation
    • {$error} (in {$mode MacPas} the directive {$errorC} is accepted, too)
    • {$warning}
    • {$hint}
    • {$note}
  • {$info}

Emission of messages can be controlled via the directives:

  • {$warn} for specific warnings, or
  • all messages of one kind in one go:
    • {$warnings}
    • {$hints}
    • {$notes}

ignored

Since FPC intends to be sort of compatible to some other compilers, some very common compiler directives stemming from the non-FPC-lands are recognized – not generating an illegal directive error – and ignored. Those are:

  • {$F} (far or near functions)
  • {$extendedSym}
  • {$externalSym}
  • {$hppEmit}
  • {$libExport}
  • {$noDefine}
  • {$region} and {$endRegion}
  • {$stringChecks} which in Delphi, this would control the generation of code that checks the sanity of string variables and arguments.

see also

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

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