• 【编辑器】VSCode配置C++编译


    传说中的编辑器有两个,vim和emacs,一个是编辑器之神,一个是神的编辑器。然后又有众多小神,是两极多强格局。 然后,软爹说,要有我,于是vscode从天而降,带着继承自vs强大的智能,体积却极其轻简,同时支持插件,而且流畅至极,一脚踏进了编辑器之战。 于是,感觉要变天了。 用着轻量的编辑器,却又想把编辑器打造成IDE,,,于是开始了Debug插件的配置。

    1、安装

    官方下载

    2、配置C++运行

    使用 VS Code 优秀的 Tasks 功能启用编译运行命令。

    新建task.json,并将内容用如下替换

    {
        "version": "2.0.0",
        "tasks": [
            {
                "label": "Build",
                "command": "g++",
                "args": [
                    "-g",
                    "-Wall",
                    "-std=c++11",
                    "-lm",
                    "${file}",
                    "-o"
                ],
                "windows": {
                    "args": [
                        "${fileDirname}/${fileBasenameNoExtension}.exe"
                    ]
                },
                "linux": {
                    "args": [
                        "${fileDirname}/${fileBasenameNoExtension}.o"
                    ]
                },
                "osx": {
                    "args": [
                        "${fileDirname}/${fileBasenameNoExtension}.o"
                    ]
                },
                "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
                }
            }
        ]
    }

    打开keybinding.json配置文件,加入如下

    {
        "key": "f5",
        "command": "workbench.action.tasks.test"
    } 

    3、配置GDB运行

    如下配置丢进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": "(gdb) Launch",
                "type": "cppdbg",
                "request": "launch",
                "program": "${fileDirname}/${fileBasenameNoExtension}.o",
                "args": [],
                "stopAtEntry": false,
                "cwd": "${workspaceFolder}",
                "externalConsole": true,
                "MIMode": "gdb",
                "windows": {
                    "program": "${fileDirname}/${fileBasenameNoExtension}.exe",
                    "miDebuggerPath": "C:/Program Files/mingw-w64/mingw64/bin/gdb.exe"
                },
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ],
                "preLaunchTask": "Build"
            }
        ]
    
    } 
  • 相关阅读:
    idea中如何配置tomcat
    onselectstart属性解决双击出现的蓝色区域
    (二十二)数组的最大值和最小值
    (二十一)数组的初始化
    (二十)两种数据类型的对比
    (十九)数组的内存分配
    (十八)数组概述
    (十六)函数的重载
    (十七)自定义函数
    (十五)函数的入栈和出栈
  • 原文地址:https://www.cnblogs.com/gwj1314/p/9444659.html
Copyright © 2020-2023  润新知