Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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:\DEV\CBCppTest\main.cpp||In function 'int main()':| D:\DEV\CBCppTest\main.cpp|22|warning: 'auto' changes meaning in C++11; please remove it [-Wc++0x-compat]| D:\DEV\CBCppTest\main.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?

like image 802
Roger Luo Avatar asked Apr 08 '12 15:04

Roger Luo


1 Answers

"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

like image 81
dexametason Avatar answered Oct 06 '22 05:10

dexametason