Sign in Join
Wiki copytemporary

$Assertions: what changed

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

Title: $Assertions

OldNewLine
1+Back to [[local compiler directives]].
2+
3+
4+The local compiler directive **$C** or **$ASSERTIONS** :
5+
6+ * is used for error detection;
7+ * determines whether an expression is compiled or not. If the directive is active, then the Assert expression is compiled.
8+
9+Examples:
10+```
11+...
12+ {$ASSERTIONS ON}
13+ ...
14+ Assert(BooleanExpression, AssertMessage);
15+ ...
16+```
17+```
18+...
19+ {$C ON}
20+ ...
21+ Assert(BooleanExpression);
22+ ...
23+```
24+
25+If the _BooleanExpression_ is false, an optional error message (AssertMessage) is output with the file name, the line number and the address and the program aborts with Runtime error 227. If _BooleanExpression_ is true, program execution continues normally. If assertions are not enabled at compile time, the Assert routine does nothing, and no code is generated for the Assert call.
26+
27+## see also
28+
29+ * [`$C` or `$ASSERTIONS`: Assertion support](<https://freepascal.org/docs-html/current/prog/progsu5.html>) in the Programmer’s Guide
30+
31+---
32+*From the Free Pascal wiki, page "$Assertions", as the Internet Archive kept it. 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