- Mastering Delphi Programming:A Complete Reference Guide
- Primo? Gabrijel?i?
- 166字
- 2021-06-24 12:33:34
Assertions
The Assertions compiler options enables or disables code generation for Assert statements. You can use compiler directives {$ASSERTIONS ON} and {$ASSERTIONS OFF} to turn this option on or off in the code. Short forms of this directive are rather cryptic {$C+} and {$C-}.
Delphi allows us to use runtime checks in the code in a form of Assert statements. Assert will check whether the first parameter evaluates to false and will raise an exception with the (optional) second parameter in an exception message, if that is true.
The following statement will raise an exception if variable i is smaller than zero:
Assert(i >= 0, 'Expecting a positive value here');
If you turn code generation for assertions off, the compiler will just skip such statements and they will not generate any code. You can for example use this to remove assertions from the release code. Even if any argument to Assert contains a function call, this function will not be called when assertions are turned off.
- Aftershot Pro:Non-destructive photo editing and management
- 網(wǎng)絡服務器配置與管理(第3版)
- Getting Started with Qt 5
- 基于Apache Kylin構(gòu)建大數(shù)據(jù)分析平臺
- Spring Cloud微服務架構(gòu)實戰(zhàn)
- 筆記本電腦維修300問
- FL Studio Cookbook
- FPGA實驗實訓教程
- Mastering Quantum Computing with IBM QX
- 微服務實戰(zhàn)
- Deep Learning with Keras
- 現(xiàn)代多媒體技術(shù)及應用
- ARM接口編程
- Practical Artificial Intelligence and Blockchain
- FPGA進階開發(fā)與實踐