void foo( char p, int size )
{
assert( p != 0 ); //确认缓冲区的指针是有效的
assert( ( size >= 100 ); //确认缓冲区至少有100个字节
// do the foo calculation
}
这些语句不产生任何代码,除非—debug处理器标志被设置。visual c++只在debug版本设置这些标志,而在release版本不定义这些标志。当—debug被定义时,两个assertions将产生如下代码:
//assert( p != 0 );
do{