首页 > 解决方案 > ubuntu 20.04 上的 Visual Studio 代码。c++ 语法检查器无法正常工作

问题描述

我正在尝试在 Ubuntu 20.04 上使用 Visual Studio Code 学习 c++17,其中包含以下内容tasks.json

{
"tasks": [
    {
        "type": "shell",
        "label": "C/C++: g++ build active file",
        "command": "/usr/bin/g++",
        "args": [
            "-std=c++2a",
            "-g",
            "${file}",
            "-o",
            "${fileDirname}/${fileBasenameNoExtension}"
        ],
        "options": {
            "cwd": "${workspaceFolder}"
        },
        "problemMatcher": [
            "$gcc"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        }
    }
],
"version": "2.0.0"
}

我有以下代码,它编译和运行良好。

#include <iostream>
#include <set>

using namespace std;

int main() {
    set<int> mSet;

    auto [iter, inserted] = mSet.insert(10);

    return 0;
}

但是语法检查器说有 3 个问题。 在此处输入图像描述

我认为我的代码没有任何问题,那么如何使 Visual Studio Code 语法检查器正常工作?

标签: c++visual-studio-codec++17

解决方案


推荐阅读