visual-studio-2010 - 如何在 Visual Studio 中启用 C++0x 功能? [初始化列表支持]

标签 visual-studio-2010 c++11

我有一些在 Ubuntu 上开发的代码,现在我正在尝试在 Windows 7(MS VS 2010)上编译它。

vector<float> tmp;
....
tmp = {3.0,4.5,9.4};

这给了我语法错误
error C2143: syntax error : missing ';' before '{'

这是因为 Visual Studio 不支持此功能吗?或者我应该在属性中启用一些开关。我将“平台工具集”属性设置为“v100”。

谢谢你。

最佳答案

Visual Studio 2010 C++ 编译器默认启用 C++0x 功能。例如,使用 lambdas 不需要额外的开关,auto等......如果您收到该错误,那很可能是因为它不受支持。

编辑

根据这篇 MSDN 文章,初始化列表不是 2010 年支持的 6 个特性之一

  • http://msdn.microsoft.com/en-us/magazine/ee336130.aspx

  • 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-2010 - 如何在 Visual Studio 中启用 C++0x 功能? [初始化列表支持],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5121529/

    相关文章:

    c# - 每当我将 UserControl 添加到窗体时,我的 UserControl 都会使 Visual Studio 崩溃

    visual-studio-2010 - 在 C# 中打印到网络打印机

    visual-studio-2010 - 在调试客户端-服务器应用程序时在解决方案中运行这两个应用程序

    c++ - 无法通过终端运行应用程序,但应用程序在 XCode 中运行良好

    c++ - 为什么 boost locale 不提供字符级规则类型?

    c++ - numeric_limits 是最小/最大常数吗?

    c# - 这个。控制不起作用

    c# - 添加 Web 引用时拒绝访问路径

    c++ - 如何将成员函数指针传递给 std::function

    c++ - 第二个线程中的 wglMakeCurrent 失败了吗?