此錯誤甚至可以在Ubuntu的 '陣列' 指令使用g ++再現:
例如,該C++代碼:
#include <iostream>
#include <array>
using namespace std;
int main(){
std::array<int, 5> myints;
cout << myints.size();
}
編寫和運行是這樣的:
g++ -o s s.cpp
./s
打印錯誤:
/usr/include/c++/4.6/bits/c++0x_warning.h:32:2: error: #error 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.
s.cpp: In function ‘int main()’:
s.cpp:6:5: error: ‘array’ is not a member of ‘std’
解決方案:
g++ -o s s.cpp -std=c++0x
./s
然後程序正確打印:使用編譯器選項-std=c++0x
編譯它
5
固定的,因爲它聽起來像你只關心編輯器的可見問題。 – 2012-08-18 18:36:27