Visual Studio Code----C+环境配置

  • .vscode文件夹(注意vscode前的.)目录下有:
    – launch.json
    – settings.json
    – tasks.json
    三个文档

以下为各个文档内容(其中部分内容请按自己计算机实际情况进行配置):
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": "c++ Launch", //配置文件的名字.因为一个launch里可以有好几个配置文件
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "E:\\mingw64\\bin\\gdb.exe",//调试器的位置
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "Build"
        }
    ]
}

settings.json

{
    "files.associations": {
        "new": "cpp",
        "iostream": "cpp",
        "limits": "cpp",
        "array": "cpp",
        "*.tcc": "cpp",
        "string": "cpp",
        "unordered_map": "cpp",
        "memory": "cpp",
        "optional": "cpp",
        "string_view": "cpp",
        "fstream": "cpp",
        "istream": "cpp",
        "ostream": "cpp",
        "vector": "cpp",
        "sstream": "cpp",
        "streambuf": "cpp",
        "tuple": "cpp",
        "bitset": "cpp",
        "chrono": "cpp",
        "algorithm": "cpp",
        "regex": "cpp",
        "valarray": "cpp",
        "deque": "cpp",
        "cctype": "cpp",
        "atomic": "cpp",
        "cfenv": "cpp",
        "charconv": "cpp",
        "cinttypes": "cpp",
        "clocale": "cpp",
        "cmath": "cpp",
        "codecvt": "cpp",
        "complex": "cpp",
        "condition_variable": "cpp",
        "csetjmp": "cpp",
        "csignal": "cpp",
        "cstdarg": "cpp",
        "cstddef": "cpp",
        "cstdint": "cpp",
        "cstdio": "cpp",
        "cstdlib": "cpp",
        "cstring": "cpp",
        "ctime": "cpp",
        "cuchar": "cpp",
        "cwchar": "cpp",
        "cwctype": "cpp",
        "forward_list": "cpp",
        "list": "cpp",
        "unordered_set": "cpp",
        "exception": "cpp",
        "functional": "cpp",
        "iterator": "cpp",
        "map": "cpp",
        "memory_resource": "cpp",
        "numeric": "cpp",
        "random": "cpp",
        "ratio": "cpp",
        "set": "cpp",
        "system_error": "cpp",
        "type_traits": "cpp",
        "utility": "cpp",
        "future": "cpp",
        "initializer_list": "cpp",
        "iomanip": "cpp",
        "iosfwd": "cpp",
        "mutex": "cpp",
        "scoped_allocator": "cpp",
        "shared_mutex": "cpp",
        "stdexcept": "cpp",
        "thread": "cpp",
        "typeindex": "cpp",
        "typeinfo": "cpp"
    },
    "C_Cpp.errorSquiggles": "Disabled"
}

tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build",
            "command": "g++",
            "args": [
                "-g",
                "-Wall",
                "-std=c++11",
                "-lm",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}.o"
            ],
            "windows": {
                "args": [
                    "-g",
                    "-Wall",
                    "-std=c++11",
                    "-lm",
                    "${file}",
                    "-o",
                    "${fileDirname}/${fileBasenameNoExtension}.exe"
                ]
            },
            "presentation": {
                "reveal": "always",
                "echo": false,
                "focus": true
            },
            "problemMatcher": {
                "owner": "cpp",
                "fileLocation": "absolute",
                "pattern": {
                    "regexp": "^(.*):(\\d+):(\\d+):\\s+(error):\\s+(.*)$",
                    "file": 1,
                    "line": 2,
                    "column": 3,
                    "severity": 4,
                    "message": 5
                }
            }
        },
        {
            "label": "Run",
            "type": "shell",
            "dependsOn": "Build",
            "command": "${fileDirname}/${fileBasenameNoExtension}.o",
            "windows": {
                "command": "${fileDirname}/${fileBasenameNoExtension}.exe"
            },
            "args": [],
            "presentation": {
                "reveal": "always",
                "focus": true
            },
            "problemMatcher": [],
            "group": {
                "kind": "test",
                "isDefault": true
            }
        }
    ]
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值