gpt4 book ai didi

c++ - boost:asio::UnregisterWaitEx 尚未声明

转载 作者:搜寻专家 更新时间:2023-10-31 00:36:46 25 4
gpt4 key购买 nike

我正在尝试使用 #include <boost/asio.hpp> 在 Eclipse 中编译基本的客户端/服务器 C++ 程序在 Win7 上使用 MinGW,我得到:

Description Resource    Path    Location    Type '::UnregisterWaitEx' has not been declared zion        line 106, external location: C:\boost_1_55_0\boost\asio\detail\impl\win_object_handle_service.ipp   C/C++ Problem

我包含路径 C:\boost_1_55_0 以及库 boost_system 和 boost_asio。

控制台输出:

 14:00:24 **** Incremental Build of configuration Debug for project boost_asio_test ****
Info: Internal Builder is used for build
g++ "-IC:\\boost_1_55_0\\" -O0 -g3 -Wall -c -fmessage-length=0 -o server.o "..\\server.cpp"
In file included from C:\boost_1_55_0/boost/bind/bind.hpp:29:0,
from C:\boost_1_55_0/boost/bind.hpp:22,
from ..\server.cpp:11:
C:\boost_1_55_0/boost/bind/arg.hpp: In constructor 'boost::arg<I>::arg(const T&)':
C:\boost_1_55_0/boost/bind/arg.hpp:37:22: warning: typedef 'T_must_be_placeholder' locally defined but not used [-Wunused-local-typedefs]
typedef char T_must_be_placeholder[ I == is_placeholder<T>::value? 1: -1 ];
^
In file included from C:\boost_1_55_0/boost/asio/detail/win_object_handle_service.hpp:180:0,
from C:\boost_1_55_0/boost/asio/windows/object_handle_service.hpp:25,
from C:\boost_1_55_0/boost/asio/windows/basic_object_handle.hpp:27,
from C:\boost_1_55_0/boost/asio.hpp:108,
from ..\server.cpp:12:
C:\boost_1_55_0/boost/asio/detail/impl/win_object_handle_service.ipp: In member function 'void boost::asio::detail::win_object_handle_service::move_construct(boost::asio::detail::win_object_handle_service::implementation_type&, boost::asio::detail::win_object_handle_service::implementation_type&)':
C:\boost_1_55_0/boost/asio/detail/impl/win_object_handle_service.ipp:106:5: error: '::UnregisterWaitEx' has not been declared
::UnregisterWaitEx(impl.wait_handle_, INVALID_HANDLE_VALUE);
^
C:\boost_1_55_0/boost/asio/detail/impl/win_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&)':
C:\boost_1_55_0/boost/asio/detail/impl/win_object_handle_service.ipp:158:5: error: '::UnregisterWaitEx' has not been declared
::UnregisterWaitEx(impl.wait_handle_, INVALID_HANDLE_VALUE);
^
C:\boost_1_55_0/boost/asio/detail/impl/win_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&)':
C:\boost_1_55_0/boost/asio/detail/impl/win_object_handle_service.ipp:200:7: error: '::UnregisterWaitEx' has not been declared
::UnregisterWaitEx(wait_handle, INVALID_HANDLE_VALUE);
^
C:\boost_1_55_0/boost/asio/detail/impl/win_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&)':
C:\boost_1_55_0/boost/asio/detail/impl/win_object_handle_service.ipp:251:7: error: '::UnregisterWaitEx' has not been declared
::UnregisterWaitEx(wait_handle, INVALID_HANDLE_VALUE);
^
C:\boost_1_55_0/boost/asio/detail/impl/win_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&)':
C:\boost_1_55_0/boost/asio/detail/impl/win_object_handle_service.ipp:302:7: error: '::UnregisterWaitEx' has not been declared
::UnregisterWaitEx(wait_handle, INVALID_HANDLE_VALUE);
^
C:\boost_1_55_0/boost/asio/detail/impl/win_object_handle_service.ipp: In static member function 'static void boost::asio::detail::win_object_handle_service::wait_callback(PVOID, BOOLEAN)':
C:\boost_1_55_0/boost/asio/detail/impl/win_object_handle_service.ipp:402:5: error: '::UnregisterWaitEx' has not been declared
::UnregisterWaitEx(impl->wait_handle_, NULL);
^
In file included from C:\boost_1_55_0/boost/asio/detail/impl/win_tss_ptr.ipp:24:0,
from C:\boost_1_55_0/boost/asio/detail/win_tss_ptr.hpp:76,
from C:\boost_1_55_0/boost/asio/detail/tss_ptr.hpp:25,
from C:\boost_1_55_0/boost/asio/detail/call_stack.hpp:20,
from C:\boost_1_55_0/boost/asio/impl/handler_alloc_hook.ipp:19,
from C:\boost_1_55_0/boost/asio/handler_alloc_hook.hpp:80,
from C:\boost_1_55_0/boost/asio/detail/handler_alloc_helpers.hpp:21,
from C:\boost_1_55_0/boost/asio/detail/bind_handler.hpp:19,
from C:\boost_1_55_0/boost/asio/detail/wrapped_handler.hpp:18,
from C:\boost_1_55_0/boost/asio/io_service.hpp:24,
from C:\boost_1_55_0/boost/asio/basic_io_object.hpp:19,
from C:\boost_1_55_0/boost/asio/basic_socket.hpp:20,
from C:\boost_1_55_0/boost/asio/basic_datagram_socket.hpp:20,
from C:\boost_1_55_0/boost/asio.hpp:21,
from ..\server.cpp:12:
C:\boost_1_55_0/boost/asio/error.hpp: At global scope:
C:\boost_1_55_0/boost/asio/error.hpp:252:45: warning: 'boost::asio::error::system_category' defined but not used [-Wunused-variable]
static const boost::system::error_category& system_category
^
C:\boost_1_55_0/boost/asio/error.hpp:254:45: warning: 'boost::asio::error::netdb_category' defined but not used [-Wunused-variable]
static const boost::system::error_category& netdb_category
^
C:\boost_1_55_0/boost/asio/error.hpp:256:45: warning: 'boost::asio::error::addrinfo_category' defined but not used [-Wunused-variable]
static const boost::system::error_category& addrinfo_category
^
C:\boost_1_55_0/boost/asio/error.hpp:258:45: warning: 'boost::asio::error::misc_category' defined but not used [-Wunused-variable]
static const boost::system::error_category& misc_category
^
In file included from C:\boost_1_55_0/boost/asio/io_service.hpp:28:0,
from C:\boost_1_55_0/boost/asio/basic_io_object.hpp:19,
from C:\boost_1_55_0/boost/asio/basic_socket.hpp:20,
from C:\boost_1_55_0/boost/asio/basic_datagram_socket.hpp:20,
from C:\boost_1_55_0/boost/asio.hpp:21,
from ..\server.cpp:12:
C:\boost_1_55_0/boost/asio/detail/winsock_init.hpp:116:30: warning: 'boost::asio::detail::winsock_init_instance' defined but not used [-Wunused-variable]
static const winsock_init<>& winsock_init_instance = winsock_init<>(false);
^
In file included from ..\server.cpp:9:0:
C:\boost_1_55_0/boost/system/error_code.hpp:222:36: warning: 'boost::system::posix_category' defined but not used [-Wunused-variable]
static const error_category & posix_category = generic_category();
^
C:\boost_1_55_0/boost/system/error_code.hpp:223:36: warning: 'boost::system::errno_ecat' defined but not used [-Wunused-variable]
static const error_category & errno_ecat = generic_category();
^
C:\boost_1_55_0/boost/system/error_code.hpp:224:36: warning: 'boost::system::native_ecat' defined but not used [-Wunused-variable]
static const error_category & native_ecat = system_category();
^

14:00:27 Build Finished (took 2s.579ms)

我试着查看 .ipp,但找不到任何有用的东西。有些东西没有声明,但我不确定是什么,也没有在 boost.org 文档中突出。

我实际上还没有尝试实现任何其他 boost 代码,因为它现在还没有编译,但这可能是需要做的事情?

我现在拥有的代码是一个使用 winsock2 的工作客户端/服务器,但我希望它也能在 linux 上工作。可能是winsock2代码和boost::asio有冲突?

最佳答案

对于 eclipse,添加符号:_WIN32_WINNT val: 0x0601(或对于您的 Windows 系统:http://msdn.microsoft.com/en-us/library/windows/desktop/aa383745%28v=vs.85%29.aspx)以解决主要问题。

WSAPOLLFD 问题是由于:https://github.com/mozilla/rust/issues/9246 && http://sourceforge.net/p/mingw/bugs/2049/通过添加修补:

typedef struct pollfd {
SOCKET fd;
short events;
short revents;
} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD;

到 winsock2.h。

关于c++ - boost:asio::UnregisterWaitEx 尚未声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20957727/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com