1.基本用法
void VectorNormalize(Vec* src, Vec* dat)
{
float length;
assert(src!=0);//检查src向量必须不为空
assert(dst!=0);//检查dst向量必须不为空
..................
..................
}
{
float length;
assert(src!=0);//检查src向量必须不为空
assert(dst!=0);//检查dst向量必须不为空
..................
..................
}
2.让assert嵌入更多的信息
void VectorNormalize(Vec* src, Vec* dst)
{
float length;
assert(src!=0 && "VectorNormalize: src vector pointer is Null");
assert(dst!=0 && "VectorNormalize: dst vector pointer is Null");
...................
...................
}
有了这个直观的字符串提示,就可以告诉当前的函数名,错误原因。
{
float length;
assert(src!=0 && "VectorNormalize: src vector pointer is Null");
assert(dst!=0 && "VectorNormalize: dst vector pointer is Null");
...................
...................
}