关于C ++中的结构化异常(SEH)我应该知道什么? [英] What should I know about Structured Exceptions (SEH) in C++?

查看:167
本文介绍了关于C ++中的结构化异常(SEH)我应该知道什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案

它们是Win32等同于Unix信号,



使用正确的编译器选项(/ EHa for Visual C ++),C ++异常使用相同的



与C ++异常不同,SEH不是类型化的,而是共享相同的数据结构其具有异常代码(原因)和关于什么代码故障以及在故障时CPU寄存器保存的附加信息。请参见 GetExceptionCode GetExceptionInformation



此外,SEH还有第一次的处理方式,允许您记录或处理异常 unwinding销毁所有本地变量。


What important points about Structured Exceptions should every C++ developer know?

解决方案

They are the Win32 equivalent to Unix signals, and let you catch CPU exceptions such as access violation, illegal instruction, divide by zero.

With the right compiler options (/EHa for Visual C++), C++ exceptions use the same mechanism as stack unwinding works properly for both C++ (user) exceptions and SEH (OS) exceptions.

Unlike C++ exceptions, SEH are not typed but all share the same data structure which has an exception code (the cause) and additional information on what code faulted and what the CPU registers held at the time of the fault. See GetExceptionCode and GetExceptionInformation for more details on this.

Also, SEH has "first-chance" handling, which allows you to log or otherwise handle the exception before unwinding destroys all the local variables.

这篇关于关于C ++中的结构化异常(SEH)我应该知道什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆