包括boost / asio.hpp抛出错误

时间:2016-07-07 21:15:09

标签: c++ visual-studio boost boost-asio

当我在头文件中使用#include时,我的程序将不再编译,出现以下错误:'boost::asio::basic_socket<Protocol,StreamSocketService>::cancel': By default, this function always fails with operation_not_supported when used on Windows XP, Windows Server 2003, or earlier. Consult documentation for details.

我也在这个项目中使用websocketpp,如果这是相关的 - 但只有在我的标题中特别包含错误时才会出现错误。

我使用的是Windows 10,Visual Studio 14。

我不知道为什么会出现这个错误。我根本不需要使用它,只需包含它。

1 个答案:

答案 0 :(得分:2)

如果查看标题文件,则会检查_WIN32_WINNT是否至少0x0600。参考this msdn page,您可以决定指定哪个版本,例如:适用于Windows Vista及更高版本的0x0600。在include语句之前指定此行:

#define _WIN32_WINNT 0x0600