为什么会发生此错误? C ++库构建

时间:2018-12-17 16:32:09

标签: c++ c++11 centos7 nghttp2

我不知道为什么会发生此错误。

我在centos 7上使用nghttp2。

我的centos支持c ++ 17

我忘了任何选择吗?

请帮助我。

谢谢。


    usr/include/c++/4.8.2/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
     #error This file requires compiler and library support for the \
      ^
    In file included from util.h:52:0,
                     from util.cc:25:
    template.h:44:19: warning: variadic templates only available with -std=c++11 or -std=gnu++11 [enabled by default]
     template <typename... T>
                       ^
    template.h:45:1: error: constexpr’ does not name a type
     constexpr std::array<
     ^
    template.h:45:1: note: C++11 ‘constexpr’ only available with -std=c++11 or -std=gnu++11
    template.h:54:33: error: constexpr’ does not name a type
     template <typename T, size_t N> constexpr size_t array_size(T (&)[N]) {
                                     ^
    template.h:54:33: note: C++11 ‘constexpr’ only available with -std=c++11 or -std=gnu++11
    template.h:58:33: error: constexpr’ does not name a type
     template <typename T, size_t N> constexpr size_t str_size(T (&)[N]) {
                                     ^
    template.h:58:33: note: C++11 ‘constexpr’ only available with -std=c++11 or -std=gnu++11
    template.h:64:31: warning: variadic templates only available with -std=c++11 or -std=gnu++11 [enabled by default]
     template <typename F, typename... T> struct Defer {
                                   ^
    template.h:65:11: error: expected ‘,’ or ‘...’ before ‘&&’ token
       Defer(F &&f, T &&... t)
               ^
    template.h:67:15: error: expected ‘,’ or ‘...’ before ‘&&’ token
       Defer(Defer &&o) noexcept : f(std::move(o.f)) {}
                   ^
    template.h:67:18: error: invalid constructor; you probably meant ‘nghttp2::Defer<F, T> (const nghttp2::Defer<F, T>&)’
       Defer(Defer &&o) noexcept : f(std::move(o.f)) {}
                      ^
    template.h:67:18: error: expected ‘;’ at end of member declaration
    template.h:67:20: error: noexcept’ does not name a type
       Defer(Defer &&o) noexcept : f(std::move(o.f)) {}
                        ^
    template.h:70:9: error: expected nested-name-specifier before ‘ResultType’
       using 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 ‘;’ before ‘=’ token
       using ResultType = typename std::result_of<typename std::decay<F>::type(
                        ^
    template.h:70:20: error: expected unqualified-id before ‘=’ token
    template.h:72:3: error: function’ in namespace ‘std’ does not name a type
       std::function<ResultType()> f;
       ^
    template.h: In constructor ‘nghttp2::Defer<F, T>::Defer(F)’:
    template.h:66:9: error: class ‘nghttp2::Defer<F, T>’ does not have any field named ‘f’
           : f(std::bind(std::forward<F>(f), std::forward<T>(t)...)) {}
             ^
    template.h:66:11: error: bind’ is not a member of ‘std’
           : f(std::bind(std::forward<F>(f), std::forward<T>(t)...)) {}
               ^
    template.h:66:11: note: suggested alternative:
    In file included from /usr/include/netinet/in.h:24:0,
                     from /usr/include/netdb.h:27,
                     from util.h:35,
                     from util.cc:25:
    ...

1 个答案:

答案 0 :(得分: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/

  

Developer Toolset是为在CentOS或Red Hat Enterprise Linux平台上工作的开发人员设计的。它提供了最新版本的GNU编译器集合,GNU调试器以及其他开发,调试和性能监视工具。