set .vscode for c++

本文详细介绍了如何在 VSCode 中配置 C++ 开发环境,包括使用 Mingw64 编译器、设置 c_cpp_properties.json 和 tasks.json 文件,以实现智能感知和自动化构建。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

reference

pre-requisite

  1. mingw64
  2. vscode and its extensions for c++
// c_cpp_properties.json
{ // >c/c++ configurations(ui)
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "D:/Apps/mingw64/bin/g++.exe", // >(ui)
            "cStandard": "c11",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "gcc-x64" // >(ui)
        }
    ],
    "version": 4
}
// tasks.json
{ // >tasks: configure default build task
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "g++.exe build",
            "command": "D:/Apps/mingw64/bin/g++.exe",
            "args": [
                "-g",
                "D:/Codes/cpp/${fileBasenameNoExtension}.cpp", // hard-coded in{.cpp}
                "-o",
                "D:/Codes/cpp/.out/${fileBasenameNoExtension}.exe" // hard_coded out{.exe}
                // "${fileDirname}/${fileBasenameNoExtension}.exe"
            ],
            "options": {
                // "cwd": "D:/Apps/mingw64/bin"
                "cwd": "D:/Apps/Git/bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build", // ctrl-shift-b to build
                "isDefault": true
            }
        }
    ]
}
// settings.json
{ // >preferences:open settings(json)
	"editor.formatOnSave": true, // ctrl-shift-x: clang-format
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值