首页 > 解决方案 > “char const * name() const _WEBSOCKETPP_NOEXCEPT_TOKEN_ {”是什么意思

问题描述

我已经把头撞在墙上一段时间了,现在试图解决这个错误,但我不明白代码在做什么。

这是我坚持的代码。它在说什么?一个返回指针的函数。“const _WEBSOCKETPP_NOEXCEPT_TOKEN_”是什么意思?它是某种定义,如果是,为什么会在这里?

char const * name() const _WEBSOCKETPP_NOEXCEPT_TOKEN_ {
    return "websocketpp";
}

这是我进入 VS 的错误代码

vs 错误的图片

    ● Started at 18:51:08
    1>------ Build started: Project: boost_thread_test, Configuration: Debug 
    x64 ------
    1>boost_thread_test.cpp
    1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\error.hpp(226): error C2259: 'websocketpp::error::category': cannot instantiate abstract class
    1>c:\librarys\socket.io-client

-cpp-master\lib\websocketpp\websocketpp\error.hpp(226): note: due to following members:
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\error.hpp(226): note: 'const char *std::error_category::name(void) noexcept const': is abstract
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(83): note: see declaration of 'std::error_category::name'
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\frame.hpp(831): warning C4267: '=': conversion from 'size_t' to 'uint32_t', possible loss of data
1>c:\librarys\socket.io-client-cpp-master\lib\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:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\processors\base.hpp(165): note: see declaration of 'websocketpp::processor::error::processor_category::name'
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(83): note: see declaration of 'std::error_category::name'
1>c:\librarys\socket.io-client-cpp-master\lib\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:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\transport\base\connection.hpp(187): note: see declaration of 'websocketpp::transport::error::category::name'
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(83): note: see declaration of 'std::error_category::name'
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\common\md5.hpp(367): warning C4267: '+=': conversion from 'size_t' to 'websocketpp::md5::md5_word_t', possible loss of data
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\sha1\sha1.hpp(176): warning C4267: '=': conversion from 'size_t' to 'unsigned int', possible loss of data
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\transport\iostream\base.hpp(77): 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:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\transport\iostream\base.hpp(77): note: see declaration of 'websocketpp::transport::iostream::error::category::name'
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(83): note: see declaration of 'std::error_category::name'
1>c:\librarys\socket.io-client-cpp-master\lib\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:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\extensions\extension.hpp(65): note: see declaration of 'websocketpp::extensions::error::category::name'
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(83): note: see declaration of 'std::error_category::name'
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\transport\asio\base.hpp(205): 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:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\transport\asio\base.hpp(205): note: see declaration of 'websocketpp::transport::asio::error::category::name'
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(83): note: see declaration of 'std::error_category::name'
1>c:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\transport\asio\security\base.hpp(107): 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:\librarys\socket.io-client-cpp-master\lib\websocketpp\websocketpp\transport\asio\security\base.hpp(107): note: see declaration of 'websocketpp::transport::asio::socket::socket_category::name'
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\system_error(83): note: see declaration of 'std::error_category::name'
1>Done building project "boost_thread_test.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
● Finished at 18:51:12 (total time 4.27s)

标签: c++socket.io

解决方案


根据https://github.com/zaphoyd/websocketpp/blob/master/websocketpp/common/cpp11.hpp 看起来它主要是noexcept.

这基本上意味着该函数不会引发任何异常。

该函数返回一个指向 const char 的 const 指针。这意味着你不能改变指针,也不能改变它指向的东西。


推荐阅读