DEBUG_ONLY

在偵錯模式 (當 _DEBUG 符號定義) 時, DEBUG_ONLY 會評估引數。

DEBUG_ONLY(expression )

備註

在發行的組建中, DEBUG_ONLY 不評估它的引數。 這是有用的,當您有應該只執行偵錯組建中的程式碼時。

DEBUG_ONLY 巨集與expression#ifdef _DEBUG 和 #endif周圍的運算式相當。

範例

void ExampleFunc(char* p, int size, char fill)
{
   char* q;               // working copy of pointer 
   VERIFY(q = p);         // copy buffer pointer and validate
   ASSERT(size >= 100);   // make sure buffer is at least 100 bytes
   ASSERT(isalpha(fill)); // make sure fill character is alphabetic 
   // if fill character is invalid, substitute 'X' so we can continue 
   // debugging after the preceding ASSERT fails.
   DEBUG_ONLY(fill = (isalpha(fill)) ? fill : 'X');
}

需求

Header: afx.h

請參閱

參考

ASSERT (MFC)

VERIFY

概念

MFC 巨集和全域