lang尝试捕获失败 [英] clang try catch fails
问题描述
这是我谈论的代码部分。
Here is the portion of code I speak about.
try {
std::cerr << "first try" << std::endl;
po::store(po::parse_config_file(ifs, _configFileOptions, false), vm);
} catch(...) {
std::cerr << "second try" << std::endl;
}
只是为了寻求细节,我使用boost program_options来解析配置文件。由于我在无法识别的文件中放置了一个选项,因此boost引发了一个异常。
Just for the seek of details , I m using boost program_options to parse a configuration file. An exception is raised by boost since I put an option in the file that is unrecognized.
Clang不能捕获此异常是一个问题。基本上我只在输出中看到
There is a problem with Clang not catching this exception. Basically I only see in the output
first try
libc++abi.dylib: terminating with uncaught exception of type boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::unknown_option> >: unrecognised option 'TestFrequency'
Abort trap: 6
这是我的clang版本:
Here is my clang version:
c++ --version
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
编辑:如果没有异常,则进行解析并且一切正常。
When there is no exception, the parsing and everything works fine.
推荐答案
对我来说,解决方案是删除链接器标志 -Wl,-no_compact_unwind(Catalina,Apple clang版本11.0.0(clang-1100.0.33.17))
For me the solution was to remove the linker flags "-Wl,-no_compact_unwind" (Catalina, Apple clang version 11.0.0 (clang-1100.0.33.17))
这篇关于lang尝试捕获失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!