TRY / CATCH_ALL vs try / catch [英] TRY/CATCH_ALL vs try/catch
问题描述
我一直在使用c ++,我熟悉正常的try / catch。然而,我现在发现自己在Windows上,编码在VisualStudio中用于COM开发。代码的几个部分使用如下:
I've been using c++ for a while, and I'm familiar with normal try/catch. However, I now find myself on Windows, coding in VisualStudio for COM development. Several parts of the code use things like:
TRY {
... do stuff
} CATCH_ALL(e) {
... issue a warning
}
END_CATCH_ALL;
这些宏的意义是什么?
What's the point of these macros? What benefit do they offer over the built-in try/catch?
我试过搜索这个,但try vs TRY很难搜索。
I've tried googling this, but "try vs TRY" is hard to search for.
推荐答案
这是一个MFC宏:
http://msdn.microsoft.com/en-us/library/t8dwzac0%28VS.71%29.aspx
此页面表示,从MFC 1.0恢复一个残余 - 在新代码中使用正常的C ++异常:
This page says they're a remnant from MFC 1.0 - use normal C++ exceptions in new code:
低于3.0的MFC版本不支持C ++异常机制。 MFC提供了处理异常的宏。
MFC versions lower than 3.0 did not support the C++ exception mechanism. MFC provided macros to deal with exceptions.
这篇关于TRY / CATCH_ALL vs try / catch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!