Visual Studio Code: launch.json

c_cpp_properties.json

cpp 复制代码
{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "D:/Kingsoft/mingw64/include/**",
                "D:/Kingsoft/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++",
                "D:/Kingsoft/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32",
                "D:/Kingsoft/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward",
                "D:/Kingsoft/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include",
                "D:/Kingsoft/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed",
                "D:/Kingsoft/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/include"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "__GNUC__=6",
                "__cdecl=__attribute__((__cdecl__))"
            ],
            "compilerPath": "D:/Kingsoft/mingw64/bin/gcc.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-x64"
        }
    ],
    "version": 4
}

launch.json

cpp 复制代码
// {
//     "version": "0.2.0",
//     "configurations": [
//         {
//             "name": "(Windows) Launch",
//             "type": "cppvsdbg",
//             "request": "launch",
//             "program": "cmd",
//             "preLaunchTask": "echo",
//             "args": [
//                 "/C",
//                 "${fileDirname}\\${fileBasenameNoExtension}.exe",
//                 "&",
//                 "echo.",
//                 "&",
//                 "pause"
//             ],
//             "stopAtEntry": false,
//             "cwd": "${workspaceFolder}",
//             "environment": [],
//             "console":"newExternalWindow"
//         },
//         {
//             "name": "(gdb) Launch",
//             "type": "cppdbg",
//             "request": "launch",
//             "targetArchitecture": "x64",
//             // "program": "C:/code/ccode1/exe/${fileBasenameNoExtension}.exe",
//             "program": "${workspaceFolder}/${fileBasenameNoExtension}.exe",
            
//             "miDebuggerPath": "D:\\Kingsoft\\mingw64\\bin\\gdb.exe",
//             "args": [],
//             "stopAtEntry": false,
//             // "cwd": "${fileDirname}",
//             // "cwd": "C:/code/ccode1/exe/",
//             "cwd": "${workspaceFolder}",
 
//             "externalConsole": true,
//             "preLaunchTask": "g++"
//         }
//     ]
// }


{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "targetArchitecture": "x64",
            "program": "${workspaceFolder}/${fileBasenameNoExtension}.exe",
            
            "miDebuggerPath": "D:\\Kingsoft\\mingw64\\bin\\gdb.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",

            "externalConsole": true,
            "preLaunchTask": "g++"
        }
    ]
}

tasks.json

cpp 复制代码
{
    "version": "2.0.0",
    "command": "g++",
    "type": "shell",
    "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": false,
        "panel": "new",//shared表示共享,改成new后每个进程创建新的端口,"panel"->"new"
        "showReuseMessage": true,
        "clear": false
    },
    "args": [
        // "-m32",
        "-fdiagnostics-color=always",
        "-g",
        "${file}",
        "-o",
        // "${fileDirname}/${fileBasenameNoExtension}.exe"
        "${workspaceFolder}/${fileBasenameNoExtension}.exe"
        // "C:/code/ccode1/exe/${fileBasenameNoExtension}.exe"

        //"-fexec-charset=GBK"
    ],//编译命令参数
    "problemMatcher": {
        "owner": "cpp",
        "fileLocation": [
            "relative",
            "${workspaceRoot}"
        ],
        "pattern": {
            "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
            "file": 1,
            "line": 2,
            "column": 3,
            "severity": 4,
            "message": 5
        }
    },
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: gcc.exe 生成活动文件",
            "command": "D:\\Kingsoft\\mingw64\\bin\\gcc.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
               "${fileDirname}\\${fileBasenameNoExtension}.exe"
                // "C:/code/ccode1/exe/${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "D:/Kingsoft/mingw64/bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "调试器生成的任务。"
        }
    ]
}
相关推荐
ZJ_.13 分钟前
WPSJS:让 WPS 办公与 JavaScript 完美联动
开发语言·前端·javascript·vscode·ecmascript·wps
jinhuazhe201311 小时前
如何解决vscode powershell乱码
ide·vscode·编辑器
mahuifa11 小时前
混合开发环境---使用编程AI辅助开发Qt
人工智能·vscode·qt·qtcreator·编程ai
paintstar14 小时前
vscode 快速切换cangjie版本
ide·vscode·编辑器·仓颉·cangjie
科协软件201814 小时前
vscode+latex快捷键
ide·vscode·编辑器
半糖112215 小时前
【VSCode】常用插件汇总
vscode·编辑器
cnnews15 小时前
在vscode中的ESP-IDF插件中使用Arduino框架作为组件
ide·vscode·编辑器
乐闻x16 小时前
VSCode 插件开发实战(三):插件配置项自定义设置
ide·vscode·编辑器
nbsaas-boot16 小时前
探索 JSON 数据在关系型数据库中的应用:MySQL 与 SQL Server 的对比
数据库·mysql·json
羊小猪~~16 小时前
前端入门之VUE--ajax、vuex、router,最后的前端总结
前端·javascript·css·vue.js·vscode·ajax·html5