vscode配置文件

需要配置以下三个文件(都可以通过新建文件的方式创建):

1.launch.json

2.settings.json

3.tasks.json


1.launch.json

一定要确保miDebuggerPath的路径正确

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}.exe",//这里是运行的.exe文件名称
            "args": [],//这里写传入命令行参数文本(main经常里面void的就不用写了)
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "targetArchitecture": "x64", 
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\Program Files\\mingw-w64\\x86_64-8.1.0-win32-seh-rt_v6-rev0\\mingw64\\bin\\gdb.exe",//写自己环境的gdb
            "preLaunchTask": "g++",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        },
    ]
}

2.settings.json

{
    "C_Cpp.errorSquiggles": "Enabled",//纠错
    "files.associations": {//文件关联
        "system_error": "c",
        "*.tcc": "cpp",
        "unordered_map": "cpp",
        "vector": "cpp",
        "array": "cpp",
        "initializer_list": "cpp",
        "utility": "cpp",
        "iostream": "cpp",
        "cmath": "cpp",
        "functional": "cpp",
        "tuple": "cpp",
        "istream": "cpp",
        "cctype": "cpp",
        "clocale": "cpp",
        "cstdint": "cpp",
        "cstdio": "cpp",
        "cstdlib": "cpp",
        "cwchar": "cpp",
        "cwctype": "cpp",
        "exception": "cpp",
        "fstream": "cpp",
        "iosfwd": "cpp",
        "limits": "cpp",
        "new": "cpp",
        "ostream": "cpp",
        "numeric": "cpp",
        "sstream": "cpp",
        "stdexcept": "cpp",
        "streambuf": "cpp",
        "type_traits": "cpp",
        "typeinfo": "cpp",
        "ctime": "cpp",
        "list": "cpp",
        "string": "cpp",
        "stdlib.h": "c",
        "math.h": "c",
        "stdio.h": "c"
    }
}

3.tasks.json

{
    "version": "2.0.0",
    "command": "g++",//执行命令
    "args": ["-g","-std=c++11","${file}","-o","${fileDirname}\\${fileBasenameNoExtension}.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
        }
    }
}
发布了21 篇原创文章 · 获赞 36 · 访问量 7242

猜你喜欢

转载自blog.csdn.net/weixin_44397852/article/details/100018610
今日推荐