考虑这个简短的代码片段,其中一个 boost::deadline_timer 中断了另一个:
#include <iostream>
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <boost/asio.hpp>
static boost::asio::io_service io;
boost::asio::deadline_timer timer1(io);
boost::asio::deadline_timer timer2(io);
static void timer1_handler1(const boost::system::error_code& error)
{
std::cout << __PRETTY_FUNCTION__ << " time:" << time(0) << " error:" << error.message() << " expect:Operation canceled." << std::endl;
}
static void timer1_handler2(const boost::system::error_code& error)
{
std::cout << __PRETTY_FUNCTION__ << " time:" << time(0) << " error:" << error.message() << " expect:success." << std::endl;
}
static void timer2_handler1(const boost::system::error_code& error)
{
std::cout << __PRETTY_FUNCTION__ << " …Run Code Online (Sandbox Code Playgroud) 我正在为我的项目使用Visual Studio 2012而且我是使用boost的新手,所以我遇到了运行时问题,试图初始化它:
FClient::FClient(const std::string & logName, const std::string & logPassword, udp::endpoint hostpoint) : mSocket(mService), mLogName(logName), mLogPassword(logPassword), mEndPoint(hostpoint)
{
}
Run Code Online (Sandbox Code Playgroud)
凡mSocket是升压UDP套接字,并MSERVICE是升压ASIO io_service对象(包括FClient的私有成员),我想调用(这基本上是串inits)的其余部分都没有检测到错误有用.我希望错误是在mSocket(mService)初始化的类型:
boost::asio::ip::udp::socket(boost::asio::io_service)
Run Code Online (Sandbox Code Playgroud)
Visual Studio调用堆栈:http: //pastebin.com/fjwWbhst
我正在使用带有1.5.6的Windows 8,我正在定义:-D_WIN32_WINNT = 0x0602
谢谢,
-lilEzek
我正在做一个包含 ASIO 的项目。我添加了库和头文件,但是当我有一个包含 的文件时asio.hpp,我收到以下错误:
1>c:\users\me\documents\of_v0.9.1_vs_release\addons\ofxasio\libs\asio-1.10.6\include\asio/detail/config.hpp(229): warning C4005: 'ASIO_ERROR_CATEGORY_NOEXCEPT': macro redefinition (compiling source file src\ofApp.cpp)
1> c:\users\me\documents\of_v0.9.1_vs_release\addons\ofxasio\libs\asio-1.10.6\include\asio/detail/config.hpp(215): note: see previous definition of 'ASIO_ERROR_CATEGORY_NOEXCEPT' (compiling source file src\ofApp.cpp)
1>c:\users\me\documents\of_v0.9.1_vs_release\addons\ofxasio\libs\asio-1.10.6\include\asio/detail/impl/win_thread.ipp(59): error C2039: 'CreateEvent': is not a member of '`global namespace'' (compiling source file src\ofApp.cpp)
1>c:\users\me\documents\of_v0.9.1_vs_release\addons\ofxasio\libs\asio-1.10.6\include\asio/detail/impl/win_thread.ipp(59): error C3861: 'CreateEvent': identifier not found (compiling source file src\ofApp.cpp)
1>c:\users\me\documents\of_v0.9.1_vs_release\addons\ofxasio\libs\asio-1.10.6\include\asio/detail/impl/win_thread.ipp(69): error C2039: 'CreateEvent': is not a member of '`global namespace'' (compiling source file src\ofApp.cpp)
1>c:\users\me\documents\of_v0.9.1_vs_release\addons\ofxasio\libs\asio-1.10.6\include\asio/detail/impl/win_thread.ipp(69): error C3861: 'CreateEvent': identifier not found (compiling source file src\ofApp.cpp) …Run Code Online (Sandbox Code Playgroud)