try/catch的实现原理

来源:互联网 发布:ubuntu 开机启动脚本 编辑:程序博客网 时间:2024/06/10 22:30

明白了几个道理,

1. VC++的try/catch是基于Win32的SEH实现的。

2. try/catch只能捕捉当前线程的异常,每个线程都有自己的异常处理入口。

3. 异常处理入口是由OS负责调用的,在异常发生时。

4. 为了使用SEH,VC++编译器自动生成了很多的代码。

 

MSDN上关于SEH的经典文章

A Crash Course on the Depths of Win32™ Structured Exception Handling
 

CodeProject上的模拟实现

How a C++ compiler implements exception handling
 

CLR的实现

The Exception Model

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/optman/archive/2008/06/03/2508323.aspx