boost system make_error_code of type errc::timed_out has message of "Unkown error"

2.1k Views Asked by At

Why does the following code output "Unknown error"? I expect some other message like "operation timed out" or other descriptive error.

OS: 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;
}
1

There are 1 best solutions below

3
On

Suggest you check include paths, library paths and project settings.

I have corrected the program (main must return an int) and compiled under 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;
}

command line:

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

result:

Operation timed out

My boost installation is installed to the prefix ${HOME}/local