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

 

你可能感兴趣的:(vscode配置文件)