2017-06-16 109 views
-1

我有以下程序。g ++ - 警告:擴展的初始值設定項列表僅在-std = C++ 11或-std = gnu ++時可用11

#include <iostream> 
#include <string> 

int main() { 
    int i {0}; 
    std::string str {"Hello World"}; 
    std::cout << i << " : " << str << std::endl; 
    return 0; 
} 

當我用g ++編譯這個時,我得到了下面的錯誤。 我正在使用g ++ 5.4。 g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609

警告:僅可擴展初始化列表-std = C++ 11或-std = GNU ++ 11

我想知道什麼是g++編譯程序的標準方法使用std::C++14和必要的標誌。

在此先感謝。

更新:

我已經與以下做到了:g++ ./ex01.cpp -o ex01.out -std=c++14 -Wall -o2

+1

* 「我在C++完全小白」 *不原諒你無法谷歌的東西。 – LogicStuff

回答

2

編譯旗:

-std=c++14

+0

它的工作原理!謝謝。 –

+0

我用下面的'g ++ ./ex01.cpp -o ex01.out -std = C++ 14 -Wall -o2' –

相關問題