Difference between revisions of "local compiler directives"

From Free Pascal wiki
m
(brand new! now with 100% more structure)
Line 1: Line 1:
 
{{local compiler directives}}
 
{{local compiler directives}}
__TOC__
 
Local directives may be used more then once in a unit or program.
 
  
==Local compiler directives==
+
Local compiler directives may be used more than once in a Pascal [[Source code|source code]] file.
*[[sAlign|$A and $ALIGN]] determines the of alignment of data in records.
 
*[[sA|$A1, $A2,$A4 and $A8]] determines the of alignment of data in records. Has the same effect as the directive $PACKRECORDS.
 
*[[sBooleval|$B or $BOOLEVAL]] enables short-cut evaluation of boolean values.
 
*[[sAssertions|$C or $ASSERTIONS]] supports debugging.
 
*[[sBitpacking|$BITPACKING]] enables bit-wise packing of records.
 
*[[sCalling|$CALLING]] determines calling-convention of routines.
 
*[[sCheckpointer|$CHECKPOINTER]] checks validity of pointers.
 
*[[sCodealign|$CODEALIGN]] determines the code-aligning in memory.
 
*[[sCoperators|$COPERATORS]] enables usage of operatores similar to conventions in the C language.
 
*[[sDefine|$DEFINE or $DEFINEC]] enables definition of own symbols.
 
*[[sExtendedsym|$EXTENDEDSYM]] ignored by compiler.
 
*[[sFar|$F]] ignored by compiler.
 
*[[sFputype|$FPUTYPE]] compiles according to FPU type
 
*[[sGoto|$GOTO]] enables Goto and Label
 
*[[sH|$H or $LONGSTRINGS]] determines string type for reserved word [[String|string]].
 
*[[sHppemit|$HPPEMIT]] ignored by compiler.
 
*[[sImplicitexeptions|$IMPLICITEXCEPTIONS]] helps to avoid memory leaks.
 
*[[sInline|$INLINE]] copies procedures to the place, where they have been called from.
 
*[[sInterfaces|$INTERFACES]] determines interface type.
 
*[[sIochecks|$I or $IOCHECKS]] enables checking of input/output.
 
*[[sIncludefile|$I or $INCLUDE]] includes file in compilation.
 
*[[sIncludecompilerinfo|$I or $INCLUDE]] included certein compiler information.
 
*[[sWritableconst|$J or $WRITEABLECONST]] enables run-time assigning of values to typed constants.
 
*[[sLink|$L or $LINK]] inserts object file during linking.
 
*[[sLinklib|$LINKLIB]] inserts library during linking.
 
*[[sTypeinfo|$M or $TYPEINFO]] creates RTTI
 
*[[sMacro|$MACRO]] enables usage of macros.
 
*[[sMinenumsize|$MINENUMSIZE]] for Delphi-compatibility, see [[sPackenum|$PACKENUM or $Z]]
 
*[[sMinfpconstprec|$MINFPCONSTPREC]] sets minimum accuracy of floating point operations.
 
*[[sNodefine|$NODEFINE]] ignored by compiler.
 
*[[sObjectchecks|$OBJECTCHECKS]] checks usage of pointer to self.
 
*[[sOptimization|$OPTIMIZATION]] switches on certain optimizations.
 
*[[sOutput_format|$OUTPUT_FORMAT]] determines output format of object file.
 
*[[sPackenum|$PACKENUM or $Z]] enables packing of compiler enumerations.
 
*[[sPackrecords|$PACKRECORDS]] determines alignment of records in memory.
 
*[[sPackset|$PACKSET]] determines packing of sets.
 
*[[sPop|$POP]] recreates saved compiler settings.
 
*[[sPush|$PUSH]] saves current compiler settings.
 
*[[sOverflowchecks|$OVERFLOWCHECKS]] checkes integer variables for overflow.
 
*[[sRangechecks|$R or $RANGECHECKS]] checks overflow of index in compound variables.
 
*[[sResource|$R or $RESOURCE]] inserts resource file.
 
*[[sStatic|$STATIC]] enable usage of the reserved word static.
 
*[[sTypedadress|$T or $TYPEDADDRESS]] determines, if the address operator @ delivers a typed or untyped pointer.
 
*[[sUndef|$UNDEF]] undefines symbol.
 
*[[sVarstringchecks|$V or $VARSTRINGCHECKS]] enables checking of assignments to string variables.
 
*[[sStackframes|$W or $STACKFRAMES]] determines conditions for the creation of stack frames.
 
*[[sWait|$WAIT]] waits with execution until the enter key has been pressed.
 
  
==Conditional compilation==
+
== syntax ==
*[[sElse|$ELSE]] defines alternative path in conditional compilation.
+
* <syntaxhighlight lang="pascal" enclose="none">{$cOperators}</syntaxhighlight> enables usage of [[Operator|operators]] similar to conventions of in the [[Pascal for C users|C]] language.
*[[sElseIf|$ELSEIF]] defines alternative and new branch conditional compilation.
+
* <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>]].
*[[sEndif|$ENDIF]] defines end of conditional compilation.
+
* <syntaxhighlight lang="pascal" enclose="none">{$inline}</syntaxhighlight> allows the [[inline|<syntaxhighlight lang="pascal" enclose="none">inline</syntaxhighlight> modifier]].
*[[$IF]] Begin of conditional compilation.
+
* [[$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>]].
*[[sIfdef|$IFDEF]] Begin of conditional compilation.
+
* <syntaxhighlight lang="pascal" enclose="none">{$macro}</syntaxhighlight> enables usage of [[Macros|macros]].
*[[sIfndef|$IFNDEF]] Begin of conditional compilation.
+
* [[$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.
*[[sIfopt|$IFOPT]] Begin of conditional compilation.
+
* [[$static|<syntaxhighlight lang="pascal" enclose="none">{$static}</syntaxhighlight>]] enable usage of the reserved word <syntaxhighlight lang="delphi" enclose="none">static</syntaxhighlight> (until FPC 3.0.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.
 +
* [[$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.
 +
* [[$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]].
  
==Self-defined compiler warnings, messages and hints==
+
== data layout ==
*[[sError|$ERROR]] display a self-defined error message.
+
* [[$align|<syntaxhighlight lang="pascal" enclose="none">{$align}</syntaxhighlight> and <syntaxhighlight lang="pascal" enclose="none">{$A}</syntaxhighlight>]] determine the alignment of data in records
*[[sFatal|$FATAL]] display a self-defined fatal error message.
+
* [[$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>.
*[[sHint|$HINT]] displays a self-defined hint.
+
* [[$codeAlign|<syntaxhighlight lang="pascal" enclose="none">{$codeAlign}</syntaxhighlight>]] determines the code-alignment in memory.
*[[sHints|$HINTS]] enables self-defined hints.
+
* <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.
*[[sInfo|$INFO]] display a self-defined information message.
+
* [[$minFPConstPrec|<syntaxhighlight lang="pascal" enclose="none">{$minFPConstPrec}</syntaxhighlight>]] sets the minimum accuracy floating-point constants are stored at.
*[[sMessage|$MESSAGE]] creates a self-defined information message.
+
* [[$packEnum|<syntaxhighlight lang="pascal" enclose="none">{$packEnum}</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">{$Z}</syntaxhighlight> enables packing of enumeration types.
*[[sNote|$NOTE]] creates a self-defined note.
+
* [[$packRecords|<syntaxhighlight lang="pascal" enclose="none">{$packRecords}</syntaxhighlight>]] determines alignment of [[Record|records]] in memory.
*[[sNotes|$NOTES]] enables the creation of self-defined notes.
+
* [[$packSet|<syntaxhighlight lang="pascal" enclose="none">{$packSet}</syntaxhighlight>]] determines packing of [[Set|sets]].
*[[sStop|$STOP]] display a self-defined fatal error message.
 
*[[sWarning|$WARNING]] creates a self-defined warning.
 
*[[sWarnings|$WARNINGS]] enables self-defined warnings.
 
  
==Local compiler directives for x86 processors only==
+
== code generation ==
*[[sAsmmode|$ASMMODE]] assembler mode.
+
* [[$boolEval|<syntaxhighlight lang="pascal" enclose="none">{$boolEval}</syntaxhighlight> and <syntaxhighlight lang="pascal" enclose="none">{$B}</syntaxhighlight>]] controls short-cut evaluation of Boolean expressions
*[[sI386xxx|$I386_XXX]] determines the assembler format.
+
* <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]]
*[[sMmx|$MMX]] enables optimizations for MMX processores.
+
* [[$calling|<syntaxhighlight lang="pascal" enclose="none">{$calling}</syntaxhighlight>]] determines the calling conventions for routines.
*[[sSaturation|$SATURATION]] Enables saturation (protection from memory-overflow) for MMX processores.
+
* [[$checkPointer|<syntaxhighlight lang="pascal" enclose="none">{$checkPointer}</syntaxhighlight>]] inserts checks ascertain validity of [[Pointer|pointers]].
*[[sMaxfpuregisters|$MAXFPUREGISTERS]] determines the maximum number of floating-points registers to use.
+
* [[$FPUtype|<syntaxhighlight lang="pascal" enclose="none">{$FPUType}</syntaxhighlight>]] compiles according to FPU type.
 +
* [[$ieeeERRORS|<syntaxhighlight lang="pascal" enclose="none">{$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.
 +
* [[$interfaces|<syntaxhighlight lang="pascal" enclose="none">{$interfacse}</syntaxhighlight>]]
 +
* [[$IOChecks|<syntaxhighlight lang="pascal" enclose="none">{$IOChecks}</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">{$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>]]
 +
* [[$optimization|<syntaxhighlight lang="pascal" enclose="none">{$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.
 +
* [[$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.
 +
* [[$stackFrames|<syntaxhighlight lang="pascal" enclose="none">{$stackFrames}</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">{$W}</syntaxhighlight>]] determines conditions for the creation of stack frames.
  
==Local compiler directives for Darwin-based operating systems only==
+
== platform-specific ==
*[[sLinkframework|$LINKFRAMEWORK]] inserts Framework.
+
=== 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.
 +
* [[$MMX|<syntaxhighlight lang="pascal" enclose="none">{$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
 +
* [[$saturation|<syntaxhighlight lang="pascal" enclose="none">{$saturation}</syntaxhighlight>]] (in conjunction with <syntaxhighlight lang="pascal" enclose="none">{$MMX}</syntaxhighlight>) enables saturation operations.
 +
* [[$maxFPUregisters|<syntaxhighlight lang="pascal" enclose="none">{$maxFPUregisters}</syntaxhighlight>]] determines the maximum number of floating-points registers to use.
  
==Local compiler directives for MacPas mode only==
+
=== other ===
The following directives are supported for compatibility with existing Pascal compilers for Mac OS:
+
* [[$linkFramework|<syntaxhighlight lang="pascal" enclose="none">{$linkFramework}</syntaxhighlight>]] inserts a framework. This directive is only available on Darwin-based operating systems.
*[[sAlign|$A and $ALIGN]] determines the alignment of data in records.
 
*[[sErrorc|$ERRORC]] returns an error message.
 
*[[sOv|$Q or $OV]] monitor overflow of integer variables.
 
  
==Symbols==
+
== data inclusion ==
*[[sDefinec|$DEFINEC]] enables definition of own symbols.
+
* [[$link|<syntaxhighlight lang="pascal" enclose="none">{$link}</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">{$L}</syntaxhighlight>]] inserts an object file during linking.
*[[sSetc|$SETC]] defines and assigns a symbol.
+
* [[$linkLib|<syntaxhighlight lang="pascal" enclose="none">{$linkLib}</syntaxhighlight>]] inserts a library during linking.
*[[sUndefc|$UNDEFC]] undefines and unassigns a symbol.
+
* [[$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]].
 +
* [[$output_format|<syntaxhighlight lang="pascal" enclose="none">{$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.
  
{{Template:Directives, Defines and Conditionals}}
+
== 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.
 +
* [[$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.
 +
* [[$push and $pop|<syntaxhighlight lang="pascal" enclose="none">{$push}</syntaxhighlight> and <syntaxhighlight lang="pascal" enclose="none">{$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" 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.
 +
 
 +
== conditional compilation ==
 +
[[Conditional compilation]] can be achieved via the directives
 +
* <syntaxhighlight lang="pascal" enclose="none">{$if}</syntaxhighlight>
 +
* <syntaxhighlight lang="pascal" enclose="none">{$else}</syntaxhighlight>
 +
* <syntaxhighlight lang="pascal" enclose="none">{$elseIf}</syntaxhighlight>
 +
* <syntaxhighlight lang="pascal" enclose="none">{$endIf}</syntaxhighlight>
 +
* <syntaxhighlight lang="pascal" enclose="none">{$ifDef}</syntaxhighlight>
 +
* <syntaxhighlight lang="pascal" enclose="none">{$ifNDef}</syntaxhighlight>
 +
* <syntaxhighlight lang="pascal" enclose="none">{$ifOpt}</syntaxhighlight>
 +
Additionally, in <syntaxhighlight lang="pascal" enclose="none">{$mode MacPas}</syntaxhighlight> the directives
 +
* <syntaxhighlight lang="pascal" enclose="none">{$ifC}</syntaxhighlight>,
 +
* <syntaxhighlight lang="pascal" enclose="none">{$elseC}</syntaxhighlight>,
 +
* <syntaxhighlight lang="pascal" enclose="none">{$elIfC}</syntaxhighlight>, and
 +
* <syntaxhighlight lang="pascal" enclose="none">{$endC}</syntaxhighlight>
 +
are allowed, too.
 +
 
 +
== compile-time behavior ==
 +
With <syntaxhighlight lang="pascal" enclose="none">{$wait}</syntaxhighlight>, the compiler waits till the user hits ↵ Enter, and then resumes compilation.
 +
 
 +
Self-defined messages can be triggered with the directives:
 +
* [[$message|<syntaxhighlight lang="pascal" enclose="none">{$message}</syntaxhighlight>]], and the shortcuts
 +
** <syntaxhighlight lang="pascal" enclose="none">{$stop}</syntaxhighlight>, which also aborts compilation
 +
** <syntaxhighlight lang="pascal" enclose="none">{$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" enclose="none">{$warning}</syntaxhighlight>
 +
** <syntaxhighlight lang="pascal" enclose="none">{$hint}</syntaxhighlight>
 +
** <syntaxhighlight lang="pascal" enclose="none">{$note}</syntaxhighlight>
 +
* <syntaxhighlight lang="pascal" enclose="none">{$info}</syntaxhighlight>
 +
 
 +
Emission of messages can be controlled via the directives:
 +
* [[$warn|<syntaxhighlight lang="pascal" enclose="none">{$warn}</syntaxhighlight>]] for specific warnings, or
 +
* all messages of one kind in one go:
 +
** <syntaxhighlight lang="pascal" enclose="none">{$warnings}</syntaxhighlight>
 +
** <syntaxhighlight lang="pascal" enclose="none">{$hints}</syntaxhighlight>
 +
** <syntaxhighlight lang="pascal" enclose="none">{$notes}</syntaxhighlight>
 +
 
 +
== 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:
 +
* <syntaxhighlight lang="pascal" enclose="none">{$F}</syntaxhighlight> (far or near functions)
 +
* <syntaxhighlight lang="pascal" enclose="none">{$extendedSym}</syntaxhighlight>
 +
* <syntaxhighlight lang="pascal" enclose="none">{$externalSym}</syntaxhighlight>
 +
* <syntaxhighlight lang="pascal" enclose="none">{$hppEmit}</syntaxhighlight>
 +
* <syntaxhighlight lang="pascal" enclose="none">{$libExport}</syntaxhighlight>
 +
* <syntaxhighlight lang="pascal" enclose="none">{$noDefine}</syntaxhighlight>
 +
* <syntaxhighlight lang="pascal" enclose="none">{$region}</syntaxhighlight> and <syntaxhighlight lang="pascal" enclose="none">{$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.
 +
 
 +
== see also ==
 +
* [https://www.freepascal.org/docs-html/prog/progse2.html § “Local directives” in the ''Free Pascal programmer’s guide'']
 +
 
 +
{{Directives, Defines and Conditionals}}

Revision as of 20:45, 23 August 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

  • {$align} and {$A} determine the alignment of data in records
  • {$bitpacking} determines, whether packed is interpreted as bitpacked.
  • {$codeAlign} determines the code-alignment in memory.
  • {$minEnumSize} recognized for Delphi-compatibility and has the same effect as the {$packEnum} directive.
  • {$minFPConstPrec} sets the minimum accuracy floating-point constants are stored at.
  • [[$packEnum|{$packEnum} or {$Z} enables packing of enumeration types.
  • {$packRecords} determines alignment of records in memory.
  • {$packSet} determines packing of sets.

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

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