Difference between revisions of "$extendedSyntax"

From Lazarus wiki
Jump to navigationJump to search
(create)
 
(use categorization template)
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 +
{{Template:{{BASEPAGENAME}}}}
 
The [[global compiler directives|global compiler directive]] <syntaxhighlight lang="pascal" inline>{$extendedSyntax on}</syntaxhighlight> turns on additional syntax.
 
The [[global compiler directives|global compiler directive]] <syntaxhighlight lang="pascal" inline>{$extendedSyntax on}</syntaxhighlight> turns on additional syntax.
 
The [[FPC]] has this by default ''on''.
 
The [[FPC]] has this by default ''on''.
Line 6: Line 7:
 
* [[Function|Functions]] can be called as if they were [[Procedure|procedures]]. The function result is discarded. This is potentially harmful if, for example, the function allocated new memory space and returned a pointer to it.
 
* [[Function|Functions]] can be called as if they were [[Procedure|procedures]]. The function result is discarded. This is potentially harmful if, for example, the function allocated new memory space and returned a pointer to it.
 
* Integer ''arithmetic'' operations are allowed on [[Pointer|pointers]]. The directive [[$pointerMath|<syntaxhighlight lang="pascal" inline>{$pointerMath}</syntaxhighlight>]] had to be ''on'' for that ''during'' the respective pointer type’s definition.
 
* Integer ''arithmetic'' operations are allowed on [[Pointer|pointers]]. The directive [[$pointerMath|<syntaxhighlight lang="pascal" inline>{$pointerMath}</syntaxhighlight>]] had to be ''on'' for that ''during'' the respective pointer type’s definition.
* Pointers become ''ordered'' and can be compared using [[Less than|<syntaxhighlight lang="pascal" inline><</syntaxhighlight>]],[[Greater than|<syntaxhighlight lang="pascal" inline>></syntaxhighlight>]], <syntaxhighlight lang="pascal" inline><=</syntaxhighlight> and <syntaxhighlight lang="pascal" inline>>=</syntaxhighlight>. ''Typed'' pointers have to correspond to each other.
+
* Pointers become ''ordered'' and can be compared using [[Less than|<syntaxhighlight lang="pascal" inline><</syntaxhighlight>]],[[Greater than|<syntaxhighlight lang="pascal" inline>></syntaxhighlight>]], <syntaxhighlight lang="pascal" inline><=</syntaxhighlight> and <syntaxhighlight lang="pascal" inline>>=</syntaxhighlight>. ''Typed'' pointers have to correspond to each other. The [[Equal|<syntaxhighlight lang="pascal" inline>=</syntaxhighlight>]] and [[Not equal|<syntaxhighlight lang="pascal" inline><></syntaxhighlight>]] comparisons work ''regardless'' of the <syntaxhighlight lang="pascal" inline>{$extendedSyntax}</syntaxhighlight> state.
  
 
== comparative remarks ==
 
== comparative remarks ==
Line 14: Line 15:
 
== see also ==
 
== see also ==
 
* [[Pascal for C users]]
 
* [[Pascal for C users]]
 
[[Category: Global compiler directives]]
 

Revision as of 16:30, 20 February 2021

Deutsch (de) English (en)


The global compiler directive {$extendedSyntax on} turns on additional syntax. The FPC has this by default on. The short notation is {$X+}/{$X‑}.

affected syntax

  • Functions can be called as if they were procedures. The function result is discarded. This is potentially harmful if, for example, the function allocated new memory space and returned a pointer to it.
  • Integer arithmetic operations are allowed on pointers. The directive {$pointerMath} had to be on for that during the respective pointer type’s definition.
  • Pointers become ordered and can be compared using <,>, <= and >=. Typed pointers have to correspond to each other. The = and <> comparisons work regardless of the {$extendedSyntax} state.

comparative remarks

see also