Ale*_*x F 6 c++ gcc exception-handling
我的项目包含共享库和exe客户端.我发现从库中抛出的我自己的异常类没有被客户端catch块捕获,并且程序以"在抛出...的实例后调用终止"消息终止.继续玩这个项目,我发现任何类型的任何例外都没有被捕获.例如,此catch不起作用:
try { m_pSerialPort = new boost::asio::serial_port(m_IoService, "non-existing-port"); } catch(const boost::system::system_error& e) { // ... }
错误信息:
terminate called after throwing an instance of 'boost::exception_detail::clone_impl <boost::exception_detail::error_info_injector <boost::system::system_error> >' what(): No such file or directory
GCC版本是4.4.1,Linux OS.相同的代码在Windows,MSVC中成功运行.什么原因可以阻止GCC程序正确捕获异常?
客户端.exe和共享库都应该与libgcc链接,以便跨越共享库边界.根据GCC手册:
...如果库或主要可执行文件应该抛出或捕获异常,则必须使用G ++或GCJ驱动程序链接它,以适合程序中使用的语言,或使用选项-shared-libgcc,以便它与共享libgcc链接.
归档时间: |
|
查看次数: |
4921 次 |
最近记录: |