首页 > 解决方案 > 向量msg {} 不是在 Mac 上的 VS Code 中为 C++ 构建

问题描述

我正在尝试在 Mac(英特尔)上配置 VS Code 以使用 C++ 进行开发。我正在关注 VS Code 网站上的设置。当我到达终端时,按照所有步骤 - 运行构建任务,构建失败并指示它需要一个“;” 在“味精”之后。我可以在 XCode 中毫无问题地运行相同的文件,但是 VS Code 失败了。这是来自 VS Code 设置站点的完整代码。

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    vector<string> msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};

    for (const string& word : msg)
    {
        cout << word << " ";
    }
    cout << endl;
}

标签: c++visual-studio-code

解决方案


推荐阅读