我到 software.opensuse.org/package/gcc5-c++ 装上了 gcc 5.1/g++ 5.1. 用以下程序试了一下,有问题了。
suse@linux-337q:~/program/cc> g++ --version
g++ (SUSE Linux) 5.1.1 20150508 [gcc-5-branch revision 222913]
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
suse@linux-337q:~/program/cc> g++ -std=c++11 -o c11nm new.cpp
suse@linux-337q:~/program/cc> ./c11nm
40
suse@linux-337q:~/program/cc> g++ -o c11mn new.cpp
new.cpp: In function ‘int main(int, char**)’:
new.cpp:10:15: error: ISO C++ forbids declaration of ‘i’ with no type -fpermissive]
for(auto& i:arr)
^
new.cpp:10:17: warning: range-based ‘for’ loops only available with -std=c++11 or -std=gnu++11
for(auto& i:arr)
^
suse@linux-337q:~/program/cc>