我正在尝试将我的 C++ 编译器更新为 C++11.我搜索了一下,得出的结论是我必须使用标志 -std=c++0x
或 -std=gnu++0x
,但是我不知道很多关于旗帜的事情.谁能帮我?(我使用的是 Ubuntu 12.04.)
当我尝试使用包含在 C++11 中的库(即数组)时,这是我从编译器中得到的错误:
#include #include int main(){std::arrayarr = {2, 3, 5};...}
<块引用>
此文件需要对即将推出的 ISO C++ 标准 C++0x 的编译器和库支持.此支持目前处于实验阶段,必须使用 -std=c++0x 或 -std=gnu++0x 编译器选项启用.
标志(或编译器选项)只不过是传递给编译器可执行文件的普通命令行参数.
假设您从命令行(终端)调用 g++:
$ g++ -std=c++11 your_file.cpp -o your_program
或
$ g++ -std=c++0x your_file.cpp -o your_program
如果上述方法不起作用.
I'm trying to update my C++ compiler to C++11.
I have searched a bit and I have come to the conclusion that I have to use the flag -std=c++0x
or -std=gnu++0x
, but I don't know many things about flags. Can anyone help me? (I'm using Ubuntu 12.04.)
Here is the error that I get from the compiler when I attempt to use a library which is included in C++11 (i.e. array):
#include <array>
#include <iostream>
int main()
{
std::array<int, 3> arr = {2, 3, 5};
...
}
This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.
Flags (or compiler options) are nothing but ordinary command line arguments passed to the compiler executable.
Assuming you are invoking g++ from the command line (terminal):
$ g++ -std=c++11 your_file.cpp -o your_program
or
$ g++ -std=c++0x your_file.cpp -o your_program
if the above doesn't work.
这篇关于用 g++ 编译 C++11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!