转:try/catch的实现原理
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
http://www.microsoft.com/msj/0197/exception/exception.aspx
深入探索Win32结构化异常处理
http://blog.youkuaiyun.com/diamont/archive/2009/06/11/4259590.aspx
CodeProject上的模拟实现
How a C++ compiler implements exception handling
CLR的实现
The Exception Model
本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/optman/archive/2008/06/03/2508323.aspx