Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
126 views
in Technique[技术] by (71.8m points)

c++ - why i cannot use the auto keyword in the last version of gcc

All, recently i tried to use the new features supported by c++11, and i wrote such statement however the compiler ran failed.

auto x = 1;

the report error listed below:

D:DEVCBCppTestmain.cpp||In function 'int main()':|
D:DEVCBCppTestmain.cpp|22|warning: 'auto' changes meaning in C++11; please remove it [-Wc++0x-compat]|
D:DEVCBCppTestmain.cpp|22|error: 'x' does not name a type|
||=== Build finished: 1 errors, 1 warnings ===|

Why the last gcc version 4.7.0 on MinGW cannot support the this statement. But the compiler of vs10 passed. Could anyone know the reason for this issue?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

"GCC provides experimental support for the 2011 ISO C++ standard. This support can be enabled with the -std=c++11 or -std=gnu++11 compiler options; the former disables GNU extension."

It comes from here: c+11 support


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...