Icy's Blog

Hi, 请登录

vscode C++调试设置

2019-03-10_21-15-23.png

设置C++的调试  首先需要安装一个mingw  下载地址 https://sourceforge.net/projects/mingw-w64/ 

安装完成配置三个文件

c_cpp_properties.json

launch.json

tasks.json

下面看看三个文件的配置

//c_cpp_properties.json的文件配置 注意修改你的安装路径 软化 \ 改成/或者 \\
{ 
    "configurations": [
        {
            "name": "Win64",
            "includePath": [
                "${workspaceRoot}",
                "D:/Program Files/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++",
                "D:/Program Files/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32",
                "D:/Program Files/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward",
                "D:/Program Files/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include",
                "D:/Program Files/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/tr1",
                "D:/Program Files/mingw64/include/include"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "__GNUC__=6",
                "__cdecl=__attribute__((__cdecl__))"
            ],
            "intelliSenseMode": "msvc-x64",
            "browse": {
                "path": [
                    "${workspaceRoot}",
                    "D:/Program Files/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++",
                    "D:/Program Files/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32",
                    "D:/Program Files/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward",
                    "D:/Program Files/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include",
                    "D:/Program Files/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/tr1",
                    "D:/Program Files/mingw64/include/include"
                ]
            },
            "limitSymbolsToIncludedHeaders": true,
            "databaseFilename": "",
            "compilerPath": "D:\\Program Files\\mingw64\\bin\\gcc.exe",
            "cStandard": "c11",
            "cppStandard": "c++17"
        }
    ],
    "version": 4
}

{//tasks.json
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "targetArchitecture": "x64",
            "program": "${workspaceRoot}\\Screen.exe",// 这里改成你输出的文件名哦
            "miDebuggerPath": "D:/Program Files/mingw64/bin/gdb.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "externalConsole": true,
            "preLaunchTask": "D:\\Program Files\\mingw64\\bin\\g++.exe",//你的安装路径
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}
{//tasks.json
    "version": "2.0.0",
    "command": "D:\\Program Files\\mingw64\\bin\\g++.exe",//  你的编译路径
    "args": [
        "-g",
        "-std=c++11",
        "main.cpp",//你的main入口的文件
        "-o",
        "${workspaceRoot}\\Screen.exe"//这里输出的文件的文件当然也要和上面启动调试的那个文件名一样咯
    ],
    "problemMatcher": {
        "owner": "cpp",
        "fileLocation": [
            "relative",
            "${workspaceRoot}"
        ],
        "pattern": {
            "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
            "file": 1,
            "line": 2,
            "column": 3,
            "severity": 4,
            "message": 5
        }
    }
}

至此VSCODE的调试编译配置完成 但是我还要装一个扩展

是VSCODE 按下 ctrl+ shift +x 搜索C++ 安装 c/c++ intellisense

好了 你可以写一个你的cpp 然后开始调试了,icy本人 用VSCODE只是写写nodejs玩的

有一天忽然心血来潮 想写写C/C++ 写写测试代码啥的还是很不错的呢 嘿嘿 祝你编码愉快.

相关推荐

评论

  • 昵称 (必填)
  • 邮箱
  • 网址