Wednesday, August 22, 2007



void assert( thePtrThatShouldNeverBeNull != NULL );

Assert is actually defined as a macro, not as a real function. In order to disable assertions when a program is found to work satisfactorily, defining the name NDEBUG before including will disable assertions totally. You should beware of side effects that the expression may have: when assertions are turned off with NDEBUG, the expression is not evaluated.

#define NDEBUG
assert( d != 22); // (not compiled) This will turn all the assert() statements off (become invisible to the compiler but not to you)

No comments:

Post a Comment