包括 boost/asio.hpp 抛出错误

Including boost/asio.hpp throwing error

当我在 header 文件中使用 #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,如果它是相关的 - 但是只有当我在我的 header.

中明确包含时才会出现错误

我正在使用 Windows 10,Visual Studio 14。

我不知道为什么会出现此错误。我根本不需要使用该库,只需包含它即可。

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

#define _WIN32_WINNT 0x0600