2017-05-05 43 views
0

我試圖編譯this頁提供的代碼。這裏的海灣合作委員會的命令,我使用:GCC要求使用-std = C++ 11即使我已經在使用它

$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輸出。

回答

6

取出-ansi開關。如果你提供多個版本交換機,那麼最新的交換機否決了以前的交換機。

+0

「ANSI」 是指C90吧?我認爲代碼需要C++ 11。我試着刪除選項 「-ansi」,但我得到了更多的錯誤(如'./util/hashint.h:13:50:ERREUR:參考 「哈希」 是不明確的size_t運營商()(const int的&I)常量{返回哈希()(i);}') – dada

+0

@dada好,這將是一個完全獨立的問題,這個問題是關於,嘗試首先整理出來,如果你不能發佈[MCVE](HTTP ://stackoverflow.com/help/mcve)遵循網站發佈指南 –

+0

並且注意[mcve]也適用於命令行,看到'-g'或'-finline-limit = 100000',那麼你可以清楚地知道你沒有儘量減少。 –

相關問題