C++ Code::Blocks“#include <array>”导致错误
C++ Code::Blocks "#include <array>" causing error
我正在使用 Code::Blocks 13.12 GNU GCC 编译器,当我尝试编译时:
#include <iostream>
#include <array>
#include <iomanip>
using namespace std;
int main()
{
array< int, 20 > c1={};
array< int, 20 > c2={};
array< int, 20 > c3={};
}
它跳转到头文件 "c++0x_warning.h" 并带有以下警告:
#ifndef _CXX0X_WARNING_H
#define _CXX0X_WARNING_H 1
#ifndef __GXX_EXPERIMENTAL_CXX0X__
#error This file requires compiler and library support for the \
ISO C++ 2011 standard. This support is currently experimental, and must be \
enabled with the -std=c++11 or -std=gnu++11 compiler options.
#endif
#endif
我做错了什么?抱歉,我刚开始学习 C++,在谷歌搜索这个问题时找不到任何有用的信息。
阅读错误消息,它告诉您确切的问题。您需要将 -std=c++11
或 -std=gnu++11
作为编译器参数传递才能使用 std::array
,它仅在 C++11 标准中引入。您的编译器支持的更高版本标准(例如 -std=c++14
)也可以使用。
对于 CodeBlocks 的具体情况,启用 C++11 支持已被询问和回答:How can I add C++11 support to Code::Blocks compiler?
我正在使用 Code::Blocks 13.12 GNU GCC 编译器,当我尝试编译时:
#include <iostream>
#include <array>
#include <iomanip>
using namespace std;
int main()
{
array< int, 20 > c1={};
array< int, 20 > c2={};
array< int, 20 > c3={};
}
它跳转到头文件 "c++0x_warning.h" 并带有以下警告:
#ifndef _CXX0X_WARNING_H
#define _CXX0X_WARNING_H 1
#ifndef __GXX_EXPERIMENTAL_CXX0X__
#error This file requires compiler and library support for the \
ISO C++ 2011 standard. This support is currently experimental, and must be \
enabled with the -std=c++11 or -std=gnu++11 compiler options.
#endif
#endif
我做错了什么?抱歉,我刚开始学习 C++,在谷歌搜索这个问题时找不到任何有用的信息。
阅读错误消息,它告诉您确切的问题。您需要将 -std=c++11
或 -std=gnu++11
作为编译器参数传递才能使用 std::array
,它仅在 C++11 标准中引入。您的编译器支持的更高版本标准(例如 -std=c++14
)也可以使用。
对于 CodeBlocks 的具体情况,启用 C++11 支持已被询问和回答:How can I add C++11 support to Code::Blocks compiler?