Sign in Join
Wiki copytemporary

$IF: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-The
2-
3-``` pascal
4-{$if …}
5-```
6-
7-directive can be used in [[Conditional compilation|conditional compilation]].
1+The `{$if …}` directive can be used in [[Conditional compilation|conditional compilation]].
82
93``` pascal
104// pointermath directive did not exist prior FPC 3.0.0
115{$if FPC_VERSION > 2}
126 // pointer arithmetics is bad. very bad
137 {$pointermath off}
148{$endif}
159```
1610
17-Also, enable you to write complex conditions that you cannot do with the
18-
19-``` pascal
20-{$ifdef …}
21-```
22-
23-,
11+Also, enable you to write complex conditions that you cannot do with the `{$ifdef …}`,
2412
2513And there are two bool functions\[defined/undefined\] that can be mixedup with \[and/or\] logic operators, For example:
2614
2715``` pascal
2816//Befor you need write these conditions to check some conditions:
2917{$define SOMETHING}
3018{$define SOMETHINGELSE}
3119{$ifdef SOMETHING}//Union $IfDef to check multiple conditions
3220 {$ifdef SOMETHINGELSE}
3321 {$ModeSwitch advancedrecords}
3422 {$endif}
3523{$endif}
3624
3725//But with the {$IF} you can check conditions together:
3826{$if defined(SOMETHING) and defined(SOMETHINGELSE)}//simple and readabl instead of union {$IFDef}`s
3927 {$ModeSwitch advancedrecords}
4028{$endif}
4129
4230{$if defined(somthing) or defined(somethingelse)}
4331 //Whatever you need!
4432{$endif}
4533
4634{$if undefined(what) and defined(somethingelse)}
4735 //Just for note, Another usage!
4836{$endif}
4937```
5038
5139---
5240*From the Free Pascal wiki, page "$IF", as it stood on 2022-08-06 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history