简体   繁体   English

g ++-警告:扩展的初始化程序列表仅在-std = c ++ 11或-std = gnu ++ 11中可用

[英]g++ - warning: extended initializer lists only available with -std=c++11 or -std=gnu++11

I've following program. 我正在关注程序。

#include <iostream>
#include <string>

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

When I compile this with g++ I got following error. 当我用g ++编译时,出现以下错误。 I'm using g++ 5.4. 我正在使用g ++ 5.4。 g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609

warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 警告:扩展的初始化程序列表仅在-std = c ++ 11或-std = gnu ++ 11中可用

I want to know what is the standard way to compile program in g++ using std::C++14 with necessary flags. 我想知道使用带有必要标志的std::C++14g++编译程序的标准方法是什么。

Thanks in Advance. 提前致谢。

Update: 更新:

I've done it with following: g++ ./ex01.cpp -o ex01.out -std=c++14 -Wall -o2 我已经完成以下操作: g++ ./ex01.cpp -o ex01.out -std=c++14 -Wall -o2

用标志编译:

-std=c++14

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM