C ++异常处理如何工作? [英] How C++ Exception handling works ?

查看:40
本文介绍了C ++异常处理如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我对C ++的实现有疑问试试catch异常处理

程序。每当有一个通过,执行必须到达点b / b
。现在,如果catch块跨越DLL边界(即

Catch块在另一个DLL中)。在这种情况下,编译器不能将

用于跳转到捕获点的代码。我认为需要来自操作系统的一些显式支持,它将在内核上下文中维护try / catch块

并且编译器将获得跳转来自

操作系统的上下文。在这种情况下,C ++编译器(支持异常处理)不能为一个本机不支持C ++的操作系统编写



I我完全糊涂了,我不知道如何实现try / catch。


请解释是否有人知道它是如何工作的。

问候,
Sahoo

Hi All,

I have a doubt in the implementation of C++ try catch exception handling
procedure. Whenever there is a through, the execution has to go to the point
of catch. Now, if the catch block resides across DLL boundary (i.e. The
Catch block is there in another DLL). In that case the compiler can not put
the code for jumping to the catch point. What I think is that there needs to
be some explicit support from the OS that would maintain the try/catch block
in the kernel context and the compiler will get the jump context from the
OS. In that case a C++ compiler (Supporting exception handling) can''t be
written for an OS which doesn''t natively support C++.

I am totally confused and i have no clue how try/catch can be implemented.

Pls explain if anyone knows how it works.
Regards,
Sahoo

推荐答案

* Subhransu Sekhar Sahoo:
* Subhransu Sekhar Sahoo:

我对此有疑问执行C ++试试catch异常处理程序。每当有一个通过时,执行必须到达捕获点。现在,如果catch块跨越DLL边界(即,另一个DLL中存在Catch块)。在这种情况下,编译器无法将代码转移到捕获点。

I have a doubt in the implementation of C++ try catch exception handling
procedure. Whenever there is a through, the execution has to go to the point
of catch. Now, if the catch block resides across DLL boundary (i.e. The
Catch block is there in another DLL). In that case the compiler can not put
the code for jumping to the catch point.




无论是什么让你认为实施''throw''作为直接跳跃?

''throw''是动态的。它最终取决于呼叫背景。


-

答:因为它弄乱了人们通常阅读文本的顺序。

问:为什么这么糟糕?

A:热门发布。

问:usenet和e中最烦人的事情是什么-mail?



Whatever made you think that a ''throw'' is implemented as a direct jump?
''throw'' is dynamic. Where it ends up depends on the call context.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


Subhransu Sekhar Sahoo写道:
Subhransu Sekhar Sahoo wrote:
大家好,

我对执行方面有疑问C ++尝试捕获异常处理程序。每当有一个通过时,执行必须到达捕获点。现在,如果catch块跨越DLL边界(即,另一个DLL中存在Catch块)。在这种情况下,编译器无法将代码放入捕获点。我认为需要来自操作系统的一些显式支持,这些支持将在内核上下文中维护try / catch块,编译器将从
OS获得跳转上下文。在这种情况下,C ++编译器(支持异常处理)不能为一个本身不支持C ++的操作系统编写。

我完全糊涂了,我不知道如何实现try / catch。

请解释是否有人知道它是如何工作的。
Hi All,

I have a doubt in the implementation of C++ try catch exception handling
procedure. Whenever there is a through, the execution has to go to the point
of catch. Now, if the catch block resides across DLL boundary (i.e. The
Catch block is there in another DLL). In that case the compiler can not put
the code for jumping to the catch point. What I think is that there needs to
be some explicit support from the OS that would maintain the try/catch block
in the kernel context and the compiler will get the jump context from the
OS. In that case a C++ compiler (Supporting exception handling) can''t be
written for an OS which doesn''t natively support C++.

I am totally confused and i have no clue how try/catch can be implemented.

Pls explain if anyone knows how it works.




这不能回答你的问题,但是你通常希望

以避免异常在模块边界上传播。


- J.



That does not answer your question, but you generally want
to avoid exceptions propagating across module boundaries altogether.

- J.


> ;这不能解答您的问题,但您通常需要
>That does not answer your question, but you generally want
来避免异常传播跨越模块边界。
- J。
to avoid exceptions propagating across module boundaries altogether. - J.




这是编译器如何处理异常的结果,还是有其他原因这样做的其他原因?

我很想知道C ++程序是否知道模块

边界。



Is this a result of how compilers handle exceptions, or are there any
other reasons for doing so?
I am curious to know whether a C++ program knows about module
boundaries.


这篇关于C ++异常处理如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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