使用Boost Asio时出错

Error while using Boost Asio

本文关键字:出错 Asio Boost 使用      更新时间:2023-10-16

我得到"::UnregisterWaitEx未声明"在win_object_handle_service。每当我试图包含

目前我在Windows 8.1上使用Code::Blocks, MinGW编译器(没有与IDE捆绑在一起)。

Boost是在mingw include文件夹之外构建的,尽管它包含在项目设置中。

我得到的确切错误:

boost_1_58_0boostasiodetailimplwin_object_handle_service.ipp||In member   function 'void       boost::asio::detail::win_object_handle_service::move_construct(boost::asio::deta il::win_object_handle_service::implementation_type&,  boost::asio::detail::win_object_handle_service::implementation_type&)':|
boost_1_58_0boostasiodetailimplwin_object_handle_service.ipp|106|error: '::UnregisterWaitEx' has not been declared|
boost_1_58_0boostasiodetailimplwin_object_handle_service.ipp||In member function 'void     boost::asio::detail::win_object_handle_service::move_assign(boost::asio::detail::win_object_handle_service::implementation_type&, boost::asio::detail::win_object_handle_service&, boost::asio::detail::win_object_handle_service::implementation_type&)':|
boost_1_58_0boostasiodetailimplwin_object_handle_service.ipp|158|error: '::UnregisterWaitEx' has not been declared|
boost_1_58_0boostasiodetailimplwin_object_handle_service.ipp||In member function 'void boost::asio::detail::win_object_handle_service::destroy(boost::asio::detail::win_object_handle_service::implementation_type&)':|
boost_1_58_0boostasiodetailimplwin_object_handle_service.ipp|200|error: '::UnregisterWaitEx' has not been declared|
boost_1_58_0boostasiodetailimplwin_object_handle_service.ipp||In member function 'boost::system::error_code boost::asio::detail::win_object_handle_service::close(boost::asio::detail::win_object_handle_service::implementation_type&, boost::system::error_code&)':|
boost_1_58_0boostasiodetailimplwin_object_handle_service.ipp|251|error: '::UnregisterWaitEx' has not been declared|
boost_1_58_0boostasiodetailimplwin_object_handle_service.ipp||In member function 'boost::system::error_code boost::asio::detail::win_object_handle_service::cancel(boost::asio::detail::win_object_handle_service::implementation_type&, boost::system::error_code&)':|
boost_1_58_0boostasiodetailimplwin_object_handle_service.ipp|302|error: '::UnregisterWaitEx' has not been declared|
boost_1_58_0boostasiodetailimplwin_object_handle_service.ipp|402|error: '::UnregisterWaitEx' has not been declared|
boost_1_58_0boostsystemerror_code.hpp|221|warning: 'boost::system::posix_category' defined but not used [-Wunused-variable]|
boost_1_58_0boostsystemerror_code.hpp|222|warning: 'boost::system::errno_ecat' defined but not used [-Wunused-variable]|
boost_1_58_0boostsystemerror_code.hpp|223|warning: 'boost::system::native_ecat' defined but not used [-Wunused-variable]|
boost_1_58_0boostasioerror.hpp|258|warning: 'boost::asio::error::system_category' defined but not used [-Wunused-variable]|
boost_1_58_0boostasioerror.hpp|260|warning: 'boost::asio::error::netdb_category' defined but not used [-Wunused-variable]|
boost_1_58_0boostasioerror.hpp|262|warning: 'boost::asio::error::addrinfo_category' defined but not used [-Wunused-variable]|
boost_1_58_0boostasioerror.hpp|264|warning: 'boost::asio::error::misc_category' defined but not used [-Wunused-variable]|
boost_1_58_0boostasiodetailwinsock_init.hpp|116|warning:    'boost::asio::detail::winsock_init_instance' defined but not used [-Wunused-variable]|

我试过了:

  1. 设置_WIN32_WINNT为0x0601(只是增加了一个警告)
  2. 在winsock2.h中添加了pollfd结构体(没有任何变化)
  3. 链接boost正则表达式,系统和线程库(或至少尝试)

提前感谢,

尼克

所以,我通过添加"-D_WIN32_WINNT=0x0501 -DWINVER=0x0501"来修复这个错误到两个编译器链接选项(在C::B)和#定义。我猜我添加了_WIN32_WINNT不知何故错误。