Export (0) Print
Expand All
TRY
Expand Minimize

DEBUG_ONLY

In debug mode (when the _DEBUG symbol is defined), DEBUG_ONLY evaluates its argument.

DEBUG_ONLY(expression )

Remarks

In a release build, DEBUG_ONLY does not evaluate its argument. This is useful when you have code that should be executed only in debug builds.

The DEBUG_ONLY macro is equivalent to surrounding expression with #ifdef _DEBUG and #endif.

Example

void example( 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( if(!isalpha(fill)) fill = 'X' );
...
}

See Also

MFC Macros and Globals | ASSERT | VERIFY

Show:
© 2014 Microsoft