- 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.
- Cortex-M3 + μC/OS-II嵌入式系統(tǒng)開發(fā)入門與應(yīng)用
- FPGA從入門到精通(實(shí)戰(zhàn)篇)
- 施耐德SoMachine控制器應(yīng)用及編程指南
- Intel FPGA/CPLD設(shè)計(jì)(高級(jí)篇)
- Svelte 3 Up and Running
- Arduino BLINK Blueprints
- Blender Game Engine:Beginner's Guide
- 3D Printing Blueprints
- IP網(wǎng)絡(luò)視頻傳輸:技術(shù)、標(biāo)準(zhǔn)和應(yīng)用
- 微服務(wù)實(shí)戰(zhàn)
- 計(jì)算機(jī)組裝與維護(hù)(慕課版)
- UML精粹:標(biāo)準(zhǔn)對(duì)象建模語(yǔ)言簡(jiǎn)明指南(第3版)
- Corona SDK Mobile Game Development:Beginner's Guide
- Advanced Machine Learning with R
- 計(jì)算機(jī)組裝與維護(hù)