Difference between revisions of "$extendedSyntax"
From Free Pascal wiki
Jump to navigationJump to search (set title case for captions) |
(remove wrong statement) |
||
Line 22: | Line 22: | ||
== Comparative remarks == | == Comparative remarks == | ||
* [[Standard Pascal]] does not define any of those “extensions”. | * [[Standard Pascal]] does not define any of those “extensions”. | ||
− | |||
== See also == | == See also == | ||
* [[Pascal for C users]] | * [[Pascal for C users]] |
Revision as of 22:35, 22 January 2022
│ 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. Nonetheless, managed data types are insusceptible to leakage. Implementing a management operator can turn any
record
into a managed data type. - Integer arithmetic expressions 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.
Notes
- If you have
{$extendedSyntax off}
, you can still do pointer arithmetic with routines from other units if they have been compiled with{$extendedSyntax on}
, for exampleinc
anddec
:Similarly, unusual comparison operations may be accessible with foreign routines.program pointerMathDemo(input, output, stdErr); {$extendedSyntax off} var p: pChar; begin p := nil; inc(p, 42); { no problem } end.
- Although with
{$extendedSyntax on}
pointers become ordered, they do not become ordinal data types; the standard functionsord
,succ
andpred
are still not applicable on pointers.
Comparative remarks
- Standard Pascal does not define any of those “extensions”.