errors compiling project with boost asio
I have created a separate project to connect my server component to clients using TCP/IP with boost::asio. I first created and tested this project separately first and tested these classes, everything worked fine.
Adding this to my server component it now no longer compiles and I get following compiler errors about code that is not even my code!
c:\Program Files\boost\boost_1_44\boost\asio\detail\impl\win_iocp_io_service.ipp(442): error C2039: 'CreateWaitableTimer' : is not a member of 'operator``global namespace'''
c:\Program Files\boost\boost_1_44\boost\asio\detail\impl\win_iocp_io_service.ipp(442): error C3861: 'CreateWaitableTimer': identifier not found, even w开发者_JS百科ith argument-dependent lookup
I have no idea why I am getting these errors, I have checked all include paths and all include files in the project.
Does anybody have any suggestions as to what can cause these errors?
The header file "tcp_server.h" is included in my project and is the one that causes the errors to pop up. This is the class defined inside this file (written by myself)
#include "stdafx.h"
#include "tcp_connection.h" //boost shared_ptr etc included inside this file already
#include <ResolverQueueHandler.h> //Handles threaded queues for requests from client
class tcp_server
{
public:
tcp_server::tcp_server(boost::asio::io_service& io_service, int port,boost::shared_ptr<ResolverQueueHandler> queue_handler);
private:
void start_accept();
void handle_accept(tcp_connection::pointer new_connection, const boost::system::error_code& error);
boost::asio::io_service _io_service;
boost::asio::ip::tcp::acceptor acceptor_;
boost::shared_ptr<ResolverQueueHandler> _queue_handler;
int _port;
};
The Windows SDK activates various operating-system specific release's additional API calls by using Preprocessor #define
s. This allows you to build applications for any version of Windows, while preventing you from inadvertently building an application that won't run on, say, Windows 98.
::CreateWaitableTimer
was added at the same time Windows 2000 was released. You'll need to add this #define
to your applications - either in a common header, or in the project settings for the appropriate C++ project:
#define _WIN32_WINNT 0x0400
References:
CreateWaitableTimer: http://msdn.microsoft.com/en-us/library/ms682492(v=vs.85).aspx
Using the Windows Headers: http://msdn.microsoft.com/en-us/library/aa383745(v=vs.85).aspx
Per this thread you have to do a #define
of _WIN32_WINNT with right version number to avoid this error.
精彩评论