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": "调试器生成的任务。"
        }
    ]
}
相关推荐
Morpheon5 小时前
Cursor 1.0 版本 GitHub MCP 全面指南:从安装到工作流增强
ide·github·cursor·mcp
猿小猴子6 小时前
主流 AI IDE 之一的 Cursor 介绍
ide·人工智能·cursor
我命由我1234512 小时前
VSCode - VSCode 放大与缩小代码
前端·ide·windows·vscode·前端框架·编辑器·软件工具
old_power14 小时前
VSCode 工作区配置文件通用模板创建脚本
ide·vscode·编辑器
Lw老王要学习14 小时前
VScode 使用 git 提交数据到指定库的完整指南
windows·git·vscode
vortex516 小时前
在 Kali 上打造渗透测试专用的 VSCode 环境
ide·vscode·编辑器
BreezeDove17 小时前
IDEA安装&迁移IDEA配置数据位置
java·ide·intellij-idea
远方160917 小时前
16-Oracle 23 ai-JSON-Relational Duality-知识准备
数据库·oracle·json
24K纯学渣17 小时前
Python编码格式化之PEP8编码规范
开发语言·ide·python·pycharm
casual_clover18 小时前
Android Studio 解决首次安装时下载 Gradle 慢问题
android·ide·android studio