如何在Windows上捕获无效的FGETPOS调用作为C ++异常?
-
15-11-2019 - |
题
在Visual C ++ 2008中,我想“捕获”如下所示生成的异常:
try {
int foo = 20;
::fgetpos(0, (fpos_t*)&foo);
}
//...
.
此处是我尝试成功捕获的调整:
解决方案
Since the code in your dump corresponds to STATUS_INVALID_CRUNTIME_PARAMETER
, try _set_invalid_parameter_handler
其他提示
Most likely, the runtime catches it for you and issues a debug dialog without returning or propagating the exception- that is a CRT call and they may add whatever exception catching code in there they like. It's well within Visual Studio's rights to catch a hardware exception inside a library function, especially if you are running from within the IDE or in debug mode, then it is expected of the runtime.
Of course, when you divide by zero, then there is no library call here to write that extra catching code.
不隶属于 StackOverflow