setup c++ 20 in vscode

first, update your g++ compiler to above g++11

in tasks.json file(automatically created while you create the project)

c 复制代码
{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++ build active file",
            "command": "/usr/bin/g++-11",
            "args": [
                "-std=g++20",
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

in settings.json file(automatically created while you click on c/c++: edit configurations(json) [ctrl + shift + p to call, require the c/c++ extension first] )

you can change your compiler here

bash 复制代码
{

    "code-runner.executorMap": {
        "cpp": "cd $dir && g++-11 -std=c++20 $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        },
    "files.associations": {
        "cctype": "cpp",
        "clocale": "cpp",
        "cmath": "cpp",
        "cstdarg": "cpp",
        "cstddef": "cpp",
        "cstdio": "cpp",
        "cstdlib": "cpp",
        "cwchar": "cpp",
        "cwctype": "cpp",
        "array": "cpp",
        "atomic": "cpp",
        "bit": "cpp",
        "*.tcc": "cpp",
        "cstdint": "cpp",
        "deque": "cpp",
        "unordered_map": "cpp",
        "vector": "cpp",
        "exception": "cpp",
        "algorithm": "cpp",
        "functional": "cpp",
        "iterator": "cpp",
        "memory": "cpp",
        "memory_resource": "cpp",
        "numeric": "cpp",
        "optional": "cpp",
        "random": "cpp",
        "string": "cpp",
        "string_view": "cpp",
        "system_error": "cpp",
        "tuple": "cpp",
        "type_traits": "cpp",
        "utility": "cpp",
        "fstream": "cpp",
        "initializer_list": "cpp",
        "iosfwd": "cpp",
        "iostream": "cpp",
        "istream": "cpp",
        "limits": "cpp",
        "new": "cpp",
        "ostream": "cpp",
        "sstream": "cpp",
        "stdexcept": "cpp",
        "streambuf": "cpp",
        "cinttypes": "cpp",
        "typeinfo": "cpp"
    }
}

in c_cpp_properties.json

bash 复制代码
{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/clang",
            "cStandard": "g20",
            "cppStandard": "g++20",
            "intelliSenseMode": "linux-clang-x64"
        }
    ],
    "version": 4
}
相关推荐
Tipriest_7 小时前
vscode settings(二):文件资源管理器&编辑功能&主题&快捷键
ide·vscode·编辑器
代码的乐趣8 小时前
支持selenium的chrome driver更新到133.0.6943.126
chrome·python·selenium
G佳伟10 小时前
【亲测有效】百度Ueditor富文本编辑器添加插入视频、视频不显示、和插入视频后二次编辑视频标签不显示,显示成img标签,二次保存视频被替换问题,解决方案
chrome·百度·音视频
汤永红10 小时前
在VSCode中接入deepseek
vscode·html·deepseek
Hylan_J15 小时前
【VSCode】MicroPython环境配置
ide·vscode·python·编辑器
mcusun200021 小时前
VScode 使用Deepseek又方便又好用的另一款插件
ide·vscode·编辑器·deepseek
luoyayun3611 天前
Trae+Qt+MSVC环境配置
vscode·qt·环境配置·trae qt
waicsdn_haha1 天前
Visual Studio Code 2025 安装与高效配置教程
c语言·ide·windows·vscode·微软·编辑器·win7
镰圈量化1 天前
当电脑上有几个python版本Vscode选择特定版本python
开发语言·vscode·python
微wx笑1 天前
chrome扩展程序如何实现国际化
前端·chrome