我创建了一个单独的项目,使用带有boost :: asio的TCP / IP将我的服务器组件连接到客户端。我首先分别创建并测试了这个项目并测试了这些类,一切正常。
将它添加到我的服务器组件中它现在不再编译,我得到关于代码甚至不是我的代码的编译器错误!
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 with argument-dependent lookup
我不知道为什么我会收到这些错误,我检查了项目中的所有包含路径和所有包含文件。
是否有人对可能导致这些错误的原因有任何建议?
头文件“tcp_server.h”包含在我的项目中,是导致错误弹出的文件。这是在这个文件中定义的类(由我自己编写)
#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;
};
答案 0 :(得分:3)
Windows SDK使用预处理器#define
激活各种特定于操作系统的版本的附加API调用。这允许您为任何版本的Windows构建应用程序,同时防止您无意中构建不能在Windows 98上运行的应用程序。
::CreateWaitableTimer
。您需要将此#define
添加到您的应用程序 - 在公共标题中,或在相应C ++项目的项目设置中:
#define _WIN32_WINNT 0x0400
参考文献:
CreateWaitableTimer:http://msdn.microsoft.com/en-us/library/ms682492(v=vs.85).aspx
使用Windows标题:http://msdn.microsoft.com/en-us/library/aa383745(v=vs.85).aspx
答案 1 :(得分:1)
每this个帖子,您必须使用正确的版本号执行#define
_WIN32_WINNT以避免此错误。