【问题标题】:gcc asks to use -std=c++11 even if I'm already using itgcc 要求使用 -std=c++11 即使我已经在使用它
【发布时间】:2017-10-03 15:47:17
【问题描述】:

我正在尝试编译this 页面中提供的代码。这是我正在使用的 gcc 命令:

$HOME/gcc-6.3.0/bin/g++ -std=c++11 -Wall -ansi -g -Wno-deprecated -I./util -finline-limit=100000 -c -o type.o type.cpp

我收到以下错误和警告:

In file included from ~/gcc-6.3.0/include/c++/6.3.0/cstdint:35:0,
                 from cluster.h:6,
                 from type.h:7,
                 from type.cpp:1:
~/gcc-6.3.0/include/c++/6.3.0/bits/c++0x_warning.h:32:2: erreur : #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support \
  ^~~~~
In file included from type.cpp:2:0:
relation.h: Dans la fonction membre « int Relation::getState(const CombNode* const&, const CombNode* const&, const int&, const bool&) »:
relation.h:1172:7: attention : this « if » clause does not guard... [-Wmisleading-indentation]
       if (cmp < 0)  return STATE_N0_BEFORE_N1;
       ^~
relation.h:1173:21: note : ...this statement, but the latter is misleadingly indented as if it is guarded by the « if »
                     return STATE_N0_AFTER_N1;
                     ^~~~~~
relation.h:1178:7: attention : this « if » clause does not guard... [-Wmisleading-indentation]
       if (cmp < 0)  return STATE_N0_AFTER_N1;
       ^~
relation.h:1179:21: note : ...this statement, but the latter is misleadingly indented as if it is guarded by the « if »
                     return STATE_N0_BEFORE_N1;
                     ^~~~~~
makefile:26 : la recette pour la cible « type.o » a échouée
make: *** [type.o] Erreur 1

我不明白的是我正在使用选项 -std=c++11,但我仍然得到“此文件需要 ISO C++ 2011 标准的编译器和库支持”。我按照错误消息的建议尝试了 -std=gnu++11 但这并没有改变 gcc 输出。

【问题讨论】:

    标签: c++ c++11 gcc compiler-errors compilation


    【解决方案1】:

    取出-ansi 开关。如果您提供多个版本切换,则最新版本会覆盖早期版本。

    【讨论】:

    • "ansi" 指的是 c90 对吧?我认为代码需要 C++11。我尝试删除选项“-ansi”,但出现更多错误(例如./util/hashint.h:13:50: erreur : reference to "hash" is ambiguous size_t operator()(const int&amp; i) const { return hash&lt;int&gt;()(i); }
    • @dada 好吧,这将是一个完全独立于这个问题的问题,尝试先解决它,如果你不能然后按照网站发布指南发布MCVE跨度>
    • 请注意minimal reproducible example 也适用于命令行,看到-g-finline-limit=100000 表明您没有尝试最小化。
    猜你喜欢
    • 1970-01-01
    • 2013-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-06
    • 2021-06-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多