VERIFY
在 MFC 调试版本,评估其参数。
VERIFY(booleanExpression )
参数
- booleanExpression
指定计算为非零或 0 的表达式 (包含指针值)。
备注
如果结果为 0,宏打印一个诊断消息并暂停程序。 如果条件为非零,则不执行任何操作。
诊断消息具有以下形式
assertion failed in file <name> in line <num>
其中,name 是源文件的名称, num 是源文件中失败的断言的行号。
在 MFC " Release "版本中,VERIFY 计算该表达式,但不打印或不中断程序。 例如,在其中如果表达式是函数调用,将调用来进行。
示例
// VERIFY can be used for things that should never fail, though
// you may want to make sure you can provide better error recovery
// if the error can actually cause a crash in a production system.
// It _is_ possible that GetDC() may fail, but the out-of-memory
// condition that causes it isn't likely. For a test application,
// this use of VERIFY() is fine. For any production code, this
// usage is dubious.
// get the display device context
HDC hdc;
VERIFY((hdc = ::GetDC(hwnd)) != NULL);
// give the display context back
::ReleaseDC(hwnd, hdc);
要求
头文件: afx.h