gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 13:17:09 24 4
gpt4 key购买 nike

为什么下面的代码会输出“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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com