websocketpp库中的错误和Windows Visual Studio 2015中的提升[关闭]
Posted
技术标签:
【中文标题】websocketpp库中的错误和Windows Visual Studio 2015中的提升[关闭]【英文标题】:Error in websocketpp library and boost in windows Visual Studio 2015 [closed] 【发布时间】:2015-10-06 11:54:05 【问题描述】:我正在尝试从开发人员 github 编译这个简单的示例 https://github.com/zaphoyd/websocketpp/blob/master/examples/echo_server/echo_server.cpp,但我在代码之外遇到了奇怪的错误。
我也尝试过打开 /Za 选项,如本文所示:VC++ 2012 and Boost incompatibility - `throw()` specifications in library headers 但它会引发不同的错误,说“线程支持不可用:它已被 BOOST_DISABLE_THREADS 明确禁用”
有人知道如何解决这个问题吗? 谢谢!
错误:
我在 Windows10 x64 中使用 Visual Studio 2015,
C:\websocketpp\websocketpp/transport/base/connection.hpp(187): error C2694: 'const char *websocketpp::transport::error::category::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const'
1> C:\websocketpp\websocketpp/transport/base/connection.hpp(187): note: see declaration of 'websocketpp::transport::error::category::name'
1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\system_error(167): note: see declaration of 'std::error_category::name'
1>C:\websocketpp\websocketpp/transport/iostream/base.hpp(89): error C2694: 'const char *websocketpp::transport::iostream::error::category::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const'
1> C:\websocketpp\websocketpp/transport/iostream/base.hpp(89): note: see declaration of 'websocketpp::transport::iostream::error::category::name'
1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\system_error(167): note: see declaration of 'std::error_category::name'
1>C:\websocketpp\websocketpp/error.hpp(151): error C2694: 'const char *websocketpp::error::category::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const'
1> C:\websocketpp\websocketpp/error.hpp(151): note: see declaration of 'websocketpp::error::category::name'
1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\system_error(167): note: see declaration of 'std::error_category::name'
1>C:\websocketpp\websocketpp/frame.hpp(831): warning C4267: '=': conversion from 'size_t' to 'uint32_t', possible loss of data
1>C:\websocketpp\websocketpp/extensions/extension.hpp(65): error C2694: 'const char *websocketpp::extensions::error::category::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const'
1> C:\websocketpp\websocketpp/extensions/extension.hpp(65): note: see declaration of 'websocketpp::extensions::error::category::name'
1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\system_error(167): note: see declaration of 'std::error_category::name'
1>C:\local\boost_1_59_0\boost/asio/detail/config.hpp(227): warning C4005: 'BOOST_ASIO_ERROR_CATEGORY_NOEXCEPT': macro redefinition
1> C:\local\boost_1_59_0\boost/asio/detail/config.hpp(213): note: see previous definition of 'BOOST_ASIO_ERROR_CATEGORY_NOEXCEPT'
1>C:\websocketpp\websocketpp/transport/asio/base.hpp(189): error C2694: 'const char *websocketpp::transport::asio::error::category::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const'
1> C:\websocketpp\websocketpp/transport/asio/base.hpp(189): note: see declaration of 'websocketpp::transport::asio::error::category::name'
1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\system_error(167): note: see declaration of 'std::error_category::name'
1>C:\websocketpp\websocketpp/transport/asio/security/base.hpp(109): error C2694: 'const char *websocketpp::transport::asio::socket::socket_category::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const'
1> C:\websocketpp\websocketpp/transport/asio/security/base.hpp(109): note: see declaration of 'websocketpp::transport::asio::socket::socket_category::name'
1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\system_error(167): note: see declaration of 'std::error_category::name'
1>C:\websocketpp\websocketpp/processors/base.hpp(165): error C2694: 'const char *websocketpp::processor::error::processor_category::name(void) const': overriding virtual function has less restrictive exception specification than base class virtual member function 'const char *std::error_category::name(void) noexcept const'
1> C:\websocketpp\websocketpp/processors/base.hpp(165): note: see declaration of 'websocketpp::processor::error::processor_category::name'
1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\system_error(167): note: see declaration of 'std::error_category::name'
1>C:\websocketpp\websocketpp/common/md5.hpp(367): warning C4267: '+=': conversion from 'size_t' to 'websocketpp::md5::md5_word_t', possible loss of data
1>C:\websocketpp\websocketpp/sha1/sha1.hpp(176): warning C4267: '=': conversion from 'size_t' to 'unsigned int', possible loss of data
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
【问题讨论】:
刚刚google了这个,找到了你的帖子,对我来说它看起来像一个错误,它不能解释VS2015有constexpr和noexcept的事实。我在 cpp11.h 中添加了异常,但现在我收到了boost::milliseconds
和 chrono 持续时间的错误。 boost::asio::basic_waitable_timer<:chrono::steady_clock>,boost::asio::waitable_timer_service定义 _WEBSOCKETPP_NOEXCEPT_
和 _WEBSOCKETPP_CPP11_CHRONO_
对我有用 :)
https://github.com/zaphoyd/websocketpp/issues/437
【讨论】:
谢谢!这对我行得通。只是为了帮助其他可能有同样问题的人,我不得不添加这个:` #define WEBSOCKETPP_NOEXCEPT 1 #define WEBSOCKETPP_CPP11_CHRONO 1 #include <...>以上是关于websocketpp库中的错误和Windows Visual Studio 2015中的提升[关闭]的主要内容,如果未能解决你的问题,请参考以下文章