所以,我正在学习一个教程,试图设置一个基本的计时器.
void print(const boost::system::error_code &e)
{
std::cout <<"hello world"<< std::endl;
}
int main()
{
boost::asio::io_service io;
boost::asio::deadline_timer timer(io, boost::posix_time::seconds(5));
timer.async_wait(print);
io.run();
}构建良好,但在运行时;
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> >'
what(): thread: The attempted operation is not supported for the type of object referencedWin7,GCC,代码::blocks
编辑;在具有相同设置的另一台计算机上试用--相同的结果。
再次编辑;我是否应该从boost 1_47切换到最新版本?
发布于 2014-08-09 03:48:30
我切换了boost 1.56,它起作用了。
发布于 2014-08-07 05:41:09
您的代码适用于我,使用MinGw 4.8和boost 1.55。但是,尝试将对timer.async_wait的调用更改为:
#include <boost/bind.hpp>
timer.async_wait(boost::bind(&print, boost::asio::placeholders::error));https://stackoverflow.com/questions/25169325
复制相似问题