-1

我不知道为什么会出现这个错误。

我在centos 7上使用nghttp2。

我的centos支持c++17

我忘记了任何选项吗?

请帮帮我。

谢谢你。

    usr/include/c++/4.8.2/bits/c++0x_warning.h:32:2:  error: #error 此文件需要编译器和库支持 ISO C++ 2011 标准。此支持目前是实验性的,必须使用 -std=c++11 或 -std=gnu++11 编译器选项启用。
     #error 此文件需要编译器和库支持 \
      ^util.h:52:0包含的文件中,
                     来自util.cc:25 :
     template.h:44:19: 警告:可变参数模板仅适用于 -std=c++11 或 -std=gnu++11 [默认启用]
     模板 <类型名... T>
                       ^ 
    template.h:45:1: 错误: '<b>constexpr' 没有命名类型
     constexpr std::array<
    ^ 
    template.h:45:1: 注意: C++11 '<b>constexpr' 仅适用于 -std=c++11 或 -std=gnu++11
     template.h:54:33:  error: ' <b>constexpr' 没有命名类型
     模板 <typename T, size_t N> constexpr size_t array_size(T (&)[N]) {
                                     ^ 
    template.h:54:33: 注意: C++11 '<b>constexpr' 仅适用于 -std=c++11 或 -std=gnu++11
     template.h:58:33:  error: ' <b>constexpr' 没有命名类型
     模板 <typename T, size_t N> constexpr size_t str_size(T (&)[N]) {
                                     ^ 
    template.h:58:33: 注意: C++11 '<b>constexpr' 仅适用于 -std=c++11 或 -std=gnu++11
     template.h:64:31: 警告:可变参数模板仅适用于 -std=c++11 或 -std=gnu++11 [默认启用]
     模板 <typename F, typename... T> struct Defer {
                                   ^ 
    template.h:65:11: 错误:在 '<b>&&' 标记之前需要 '<b>,' 或 '<b>...'
       推迟(F &&f, T &&... t)
               ^ 
    template.h:67:15: 错误: '<b>,' 或 '<b>...' 在 '<b>&&' 标记之前
       Defer(Defer &&o) noexcept : f(std::move(of)) {}
                   ^ 
    template.h:67:18: 错误:无效的构造函数;你的意思可能是'<b>nghttp2::Defer<F, T> (const nghttp2::Defer<F, T>&)'
       Defer(Defer &&o) noexcept : f(std::move(of)) {}
                      ^ 
    template.h:67:18: 错误:预期 '<b>;' 在成员声明
    template.h:67:20 结束时: 错误: '<b>noexcept' 没有命名类型
       Defer(Defer &&o) noexcept : f(std::move(of)) {}
                        ^ 
    template.h:70:9: 错误: '<b>ResultType' 之前的预期嵌套名称说明符
       使用 ResultType = typename std::result_of<typename std::decay<F>::type(
             ^ 
    template.h:70:9:  error: using-declaration for non-member at class scope
     template.h:70:20:  error: expected '<b>;' 在 '<b>=' 标记之前
       使用 ResultType = typename std::result_of<typename std::decay<F>::type(
                        ^ 
    template.h:70:20: 错误: '<b>=' 标记
    template.h:72:3: 错误:名称空间'<b>std' 中的'<b>function' 没有命名一种
       std::function<ResultType()> f;
       ^ 
    template.h:在构造函数'<b>nghttp2::Defer<F, T>::Defer(F)':
     template.h:66:9:  error: class '<b>nghttp2::Defer<F, T>' 没有任何名为 '<b>f' 的字段
           : f(std::bind(std::forward<F>(f), std::forward<T>(t)...)) {}
             ^ 
    template.h:66:11: 错误: '<b>bind' 不是 '<b>std' 的成员
           : f(std::bind(std::forward<F>(f), std::forward<T>(t)...)) {}
               ^ 
    template.h:66:11: 注意:建议的替代方案:
    在/usr/include/netinet/in.h:24:0包含的文件中,
                     从/usr/include/netdb.h:27,
                     从util.h:35,
                     来自util.cc:25:
    ...

4

1 回答 1

7

我忘记了任何选项?

你做到了,编译器准确地告诉你:

错误:#error 此文件需要对 ISO C++ 2011 标准的编译器和库支持。此支持目前是实验性的,必须使用 -std=c++11 或 -std=gnu++11 编译器选项启用


您可能正在使用一个非常旧的编译器(默认情况下 CentOS 附带的那个)。

您需要安装提供最新版本的 Red Hat Developer Toolset,有关详细信息,请参阅https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/ :

开发者工具集专为在 CentOS 或 Red Hat Enterprise Linux 平台上工作的开发者而设计。它提供了当前版本的 GNU 编译器集合、GNU 调试器以及其他开发、调试和性能监控工具。

于 2018-12-17T16:36:11.930 回答