【发布时间】:2015-07-19 20:12:06
【问题描述】:
我想将 Boost.Filesystem 与 -fno-exceptions 一起使用。根据Boost.Filesystem documentation,它声明它支持BOOST_NO_EXCEPTIONS 宏。
不过,下面snippet:
#define BOOST_NO_EXCEPTIONS
#include <boost/filesystem.hpp>
int main() {}
编译:
g++ -fno-exceptions boost_test.cpp
给出错误:
/.../boost/filesystem/operations.hpp:在构造函数中 'boost::filesystem::filesystem_error::filesystem_error(const string&, boost::system::error_code)': /.../boost/filesystem/operations.hpp:84:16: 错误: 禁用异常处理,使用 -fexceptions 启用 捕捉 (...) { m_imp_ptr.reset(); }
我在 Mac OSX 上使用 gcc 5 和 boost 1.57 版进行编译(也在类似的 ubuntu 设置上进行了测试)。
我想知道我对BOOST_NO_EXCEPTIONS 的理解是否正确,它应该涵盖-fno-exceptions 的用法,或者它是否只是用于boost::throw_exception 部分?
【问题讨论】:
-
用 Clang 3.6 为我编译,可以用 GCC 5.1 重现。