c++ - errc::timed_out 类型的 boost 系统 make_error_code 具有 "Unkown error"消息

标签 c++ boost boost-system

为什么下面的代码会输出“Unknown error”?我期待一些其他消息,例如“操作超时”或其他描述性错误。

操作系统:Windows 7 boost :1.57

#include <iostream>
#include "boost/system/system_error.hpp"

void main()
{
    boost::system::error_code ec = make_error_code(boost::system::errc::timed_out);
    auto message = ec.message();
    std::cout << message << std::endl;
}

最佳答案

建议您检查包含路径、库路径和项目设置。

我已经更正了程序(main 必须返回一个 int)并在 clang 下编译:

#include <iostream>
#include <boost/system/system_error.hpp>

int main()
{
    boost::system::error_code ec = make_error_code(boost::system::errc::timed_out);
    auto message = ec.message();
    std::cout << message << std::endl;
}

命令行:

c++ -std=c++14 -I${HOME}/local/include -L${HOME}/local/lib -lboost_system

结果:

Operation timed out

我的boost安装安装到前缀${HOME}/local

关于c++ - errc::timed_out 类型的 boost 系统 make_error_code 具有 "Unkown error"消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36851384/

相关文章:

c++ - MFC静态库和外部rc(resource)文件图标加载问题

c++ - 范围枚举 : error: cannot convert ‘int’ to ‘Handle’ in initialization

c++ - 使用 dynamic_quadratic boost rtree 中的打包算法

c++ - 何时需要运行 io_service 以及为什么

winapi - 如何获得英文的 boost::system::error_code::message?

c++ - alutCreateBufferHelloWorld() 中的openal

c++ - 在模板函数 C++ 中的 F&&,Args &&... 参数之后添加另一个函数作为参数

c++ - 如何在 C++ 中使用 BOOST_AUTO 模拟 'const auto'?

c++ - 使用 boost 的运行时错误 - undefined symbol : _ZN5boost6system15system_categoryEv

c++ - 尽管与 boost_system 链接,但对 boost::system::generic_category 的 undefined reference