- 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.
- 深入理解Spring Cloud與實(shí)戰(zhàn)
- 顯卡維修知識(shí)精解
- 電腦軟硬件維修大全(實(shí)例精華版)
- 計(jì)算機(jī)組裝與系統(tǒng)配置
- SDL Game Development
- 辦公通信設(shè)備維修
- 電腦軟硬件維修從入門(mén)到精通
- Apple Motion 5 Cookbook
- Building 3D Models with modo 701
- 面向?qū)ο蠓治雠c設(shè)計(jì)(第3版)(修訂版)
- 固態(tài)存儲(chǔ):原理、架構(gòu)與數(shù)據(jù)安全
- LPC1100系列處理器原理及應(yīng)用
- WebGL Hotshot
- Blender 3D By Example
- 嵌入式系統(tǒng)設(shè)計(jì)大學(xué)教程(第2版)