VERIFY

在 MFC 偵錯版本,會評估其引數。

VERIFY(booleanExpression )

參數

  • booleanExpression
    指定運算式 (包括指標值),其值為非零值或 0。

備註

如果結果為 0,該巨集列印診斷訊息,並會中止程式。如果條件為非零值,就沒有作用。

診斷訊息有格式

assertion failed in file <name> in line <num>

其中名稱 的原始程式檔的名稱和 num 是原始程式檔中的失敗,表示判斷提示的行號。

在發行版本的 MFC 中, 驗證不會評估運算式,但會列印或中斷程式。比方說,如果運算式是函式呼叫,將會進行呼叫。

範例

// 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

請參閱

參考

ASSERT (MFC)

概念

MFC 巨集和全域變數