"捕捉"无法从库中捕获异常

时间:2018-05-14 11:18:16

标签: c++ linux exception

我在库中有这个方法:

#include <stdexcept>

mytype* myfunc()
{
  throw std::runtime_error("is uncatchable");
}

int main()链接库的可执行进程。

  try {  myfunc(); }
  catch(std::exception const& ex) { std::cout << "handled: " << ex.what() << std::endl;  }
  catch(...) {   std::cout << "something else..." << std::endl;  }

这就是输出:

terminate called after throwing an instance of 'std::runtime_error'
  what(): is uncatchable
Abort (core dumped)

问题: 为什么例外没有捕获?

我没有管理我的编译器标志(icc-11.X),操作系统也不在我的控制之下。

编译器标志列表:

-DLINUX -DLINUX_X64 -DGNU_SOURCE -fPIC -Wcheck -Wshadow -Wdeprecated -Wreturn-type -Wcomment -Wmissing-prototypes -Wp64 -Drcsid="__attribute__((used)) rcsid" 
-D__EXTENSIONS__ -D__STD_C__ -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -DNDEBUG  

__EXCEPTIONS已定义。

是否存在导致此问题的Linux设置?

是否存在导致此问题的编译器设置?

0 个答案:

没有答案
相关问题