为什么我不能使用auto关键字在最后一个版本的gcc [英] why i cannot use the auto keyword in the last version of gcc
本文介绍了为什么我不能使用auto关键字在最后一个版本的gcc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所有,最近我试图使用c ++ 11支持的新功能,我写了这样的语句,但编译器运行失败。
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;
下面列出的报告错误:
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 ===|
为什么MinGW上的最后一个gcc版本4.7.0不能支持this语句。但编译的vs10通过了。
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?
推荐答案
GCC为2011年ISO C ++标准提供实验性支持,使用-std = c ++ 11或-std = gnu ++ 11编译器选项启用;前者禁用GNU扩展。
"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."
它来自这里: c + 11支持
这篇关于为什么我不能使用auto关键字在最后一个版本的gcc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文