Visual Studio コード: launch.json

c_cpp_properties.json

{
    "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
}

起動.json

// {
//     "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++"
        }
    ]
}

タスク.json

{
    "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": "调试器生成的任务。"
        }
    ]
}

おすすめ

転載: blog.csdn.net/m0_72572822/article/details/132631128