本文介绍了捕获访问冲突异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道访问冲突不是标准C ++

异常处理支持的一部分。在Windows上,一个特定的MSVC编译器

选项启用Microsoft的C ++结构化异常处理(SEH)

EH,这样一个catch(...)将捕获一个访问违规。我不知道

如果其他平台支持类似的东西。


我想知道如何最好地保护应用程序或库免受

写得不好的用户定义的回调。能够

自动取消注册用户定义的回调,如果发现

导致任何异常,包括访问冲突,那将是很好的。有没有人知道

a平台独立的方法来实现这个目标?


问候和TIA,


史蒂文

I understand that access violations aren''t part of the standard C++
exception handling support. On Windows, a particular MSVC compiler
option enables Microsoft''s Structured Exception Handling (SEH) in C++
EH so that a catch (...) will catch an access violation. I don''t know
if other platforms support something similar.

I''m wondering about how to best protect an application or library from
poorly written user-defined callbacks. It would be nice to be able to
automatically unregister a user-defined callback if it is found to
cause any exception including access violations. Does anyone know of
a platform-independant method for achieving this?

Regards and TIA,

Steven

推荐答案




怎么会有?您是否认为所有平台甚至都会定义访问违规?


例如记住MS-DOS,你可以在任何你喜欢的地方戳一根棍子

?有时你会用棍子引爆一个地雷

,操作系统就会消失。没有''访问

违规'',没有错误信息,没有。


你认为那些定义''访问冲突'的平台''br />
在那个术语中意思相同吗?


-Mike



How could there be? Do you think all platforms even
define ''access violation''?

E.g. remember MS-DOS, where you could poke a stick
anywhere you liked? Sometimes you''d detonate a mine
with the stick, and the OS just ''went away''. No ''access
violation'', no error message, nothing.

Do you think those platforms that do define ''access violation''
mean the same thing by that term?

-Mike





不要使用catch(...)。发送电子邮件给Abrahams / Sutter / ...要求

修复C ++ EH。他们应该要求两阶段EH和修改例外

规范(使ES工作没有完全愚蠢的捕获(...)),开始时。

像bool expected_exception< ; T>()和bool展开(T *)也可以跟随



问候,

亚历山大。



Don''t use catch(...). Send an email to Abrahams/Sutter/... demanding
a fix for C++ EH. They shall mandate 2-phase EH and amended exception
specs (make ES work without totally silly catch(...)), to begin with.
Things like bool expected_exception<T>() and bool unwinding(T *) can
follow as well.

regards,
alexander.





No.


您可以在图书馆这样做,但这不是一项微不足道的任务。



No.

You could a library to do this but it''s not a trivial task.


这篇关于捕获访问冲突异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 06:51
查看更多