vscode+msvc調試c++程序

1. 打開vs工具命令提示

我的在文件夾C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts中:
在這裏插入圖片描述
選行x86或其他幾個都行,雙擊運行

2. 執行code打開vscode

在這裏插入圖片描述

3. 配置settings.json

{
    "terminal.integrated.shell.windows": "C:/WINDOWS/System32/cmd.exe"
}

4. 配置launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "msvc launch",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "preLaunchTask": "msvc build"
        }
    ]
}

5. 配置tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "msvc build",
            "command": "cl.exe",
            "args": [
                "/Zi",
                "/EHsc",
                "/Fe:",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
                "${file}"
            ],
            "problemMatcher": [
                "$msCompile"
            ],
            "group": "build"
        }
    ]
}

6. 調試

直接在主函數文件中F5啓動調試。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章