如何在 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."
谢谢.
推荐答案
C++0x 功能在 Visual Studio 2010 C++ 编译器上默认启用.例如,使用 lambdas、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
Visual Studio 2010 中的 Visual C++ 编译器支持六项 C++0x 核心语言功能:lambda 表达式、auto 关键字、右值引用、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屋!