请问各位大虾,下面这段代码在Debug 模式下编译后执行可以捕获到异常,但是在Release模式下编译了却捕获不到了,请各位高手赐教。 CString ch;
try{
int b=0;
int a=10/b;
ch.Format ("%s",a);
AfxMessageBox(ch);
}
catch(...){
AfxMessageBox("error");
}
try{
int b=0;
int a=10/b;
ch.Format ("%s",a);
AfxMessageBox(ch);
}
catch(...){
AfxMessageBox("error");
}
选择优化为Default
你禁用优化呢?
/Og /D
但是三个优化条件好象都不满足
Local and global common subexpression elimination
Automatic register allocation
Loop optimization不知道应用的那条规则优化
其实自己查一下MSDN就能够解决才对
不过难得今天登陆一次,就顺便水一下吧
int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep) {
if (code == EXCEPTION_ACCESS_VIOLATION) {
return EXCEPTION_EXECUTE_HANDLER;
}
else {
return EXCEPTION_CONTINUE_SEARCH;
}
}
__try{
....
}
__except(filter(GetExceptionCode(), GetExceptionInformation())){
return false;
}