From Free Pascal wiki
Revision as of 18:40, 25 May 2019 by Mamrezo (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

The {$if …} directive can be used in conditional compilation.

// pointermath directive did not exist prior FPC 3.0.0
{$if FPC_VERSION > 2}
	// pointer arithmetics is bad. very bad
	{$pointermath off}

Also, enable you to write complex conditions that you cannot do with the {$ifdef …},

And there are two bool functions[defined/undefined] that can be mixedup with [and/or] logic operators, For example:

//Befor you need write these conditions to check some conditions:
{$define SOMETHING}
{$ifdef SOMETHING}//Union $IfDef to check multiple conditions
   {$ModeSwitch advancedrecords}

//But with the {$IF} you can check conditions together:
{$if defined(SOMETHING) and defined(SOMETHINGELSE)}//simple and readabl instead of union {$IFDef}`s
  {$ModeSwitch advancedrecords}

{$if defined(somthing) or defined(somethingelse)}
  //Whatever you need!

{$if undefined(what) and defined(somethingelse)}
  //Just for note, Another usage!
Directives, definitions and conditionals definitions
global compiler directives • local compiler directives

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