如何在Visual Studio中启用C ++ 0x功能? [初始化列表支持] [英] How to enable C++0x features in Visual studio? [Initializer Lists support]
问题描述
我有一些在Ubuntu上开发的代码,现在我正在尝试在Windows 7(MS VS 2010)上对其进行编译。
I had some code that I developed on Ubuntu and now I am trying to compile it on Windows 7 (MS VS 2010).
vector<float> tmp;
....
tmp = {3.0,4.5,9.4};
这给我带来语法错误
error C2143: syntax error : missing ';' before '{'
这是因为Visual Studio不支持此功能吗?还是应该在属性中启用一些开关。我将平台工具集属性设置为 v100。
Is this because Visual studio doesn't support this feature ? or should I be enabling some switch in the properties. I have the "Platform Toolset" property set to "v100."
谢谢。
推荐答案
默认情况下,Visual Studio 2010 C ++编译器会启用C ++ 0x功能。不需要额外的开关,例如使用lambda, auto
等。。。如果遇到此错误,是因为很可能不支持该错误。
The C++0x features are enabled by default on the Visual Studio 2010 C++ compiler. It takes no extra switches for example to use lambdas, auto
, etc ... If you're getting that error it's because in all likelyhood it's not supported.
编辑
根据此MSDN文章,初始值设定项列表不是其中之一2010年支持的6种功能
Based on this MSDN article, initializer lists are not one of the 6 supported features in 2010
- http://msdn.microsoft.com/en-us/magazine/ee336130.aspx
Visual Studio 2010中的Visual C ++编译器启用六种C ++ 0x核心语言功能:lambda表达式,auto关键字,rvalue引用,static_assert,nullptr和decltype
the Visual C++ compiler in Visual Studio 2010 enables six C++0x core language features: lambda expressions, the auto keyword, rvalue references, static_assert, nullptr and decltype
这篇关于如何在Visual Studio中启用C ++ 0x功能? [初始化列表支持]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!