VScode配置c/c++

2019-08-05  本文已影响0人  Searainbow

配置文件有些Python的配置

环境

Deepin linux

1.首先是c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

2.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/C++ (gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}", //程序可执行文件的路径
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}", 
            "environment": [],
            "externalConsole": false, //设为false时使用集成终端,true为外置终端
            "linux": {
                "MIMode": "gdb",
                "miDebuggerPath": "/usr/bin/gdb"
            },
            "windows": {
                "MIMode": "gdb",
                "miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe"
            },
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "build"
        }

        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        }
    ]
}

3.settings.json

{
    "python.pythonPath": "/usr/bin/python",
    "git.ignoreLimitWarning": true
}

4.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", //相当与名字,与后面launch.json中preLaunchTask参数要保持一致
            "type": "shell",
            "command": "g++", 
            "args": [     //编译所需要的参数,包括编译方式,源文件,和生成的可执行文件
                "-g",
                "-Wall",
                "-std=c++17",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "presentation": {   //控制终端显示
                "echo": true,
                "reveal": "always",
                "focus": false,
                "panel": "shared",
                "showReuseMessage": false,
                "clear": true
            },
        },
        {
            "label": "run",
            "type": "shell",
            "dependsOn": ["build"], //依赖的配置,运行之前需要编译链接形成可执行文件
            "command": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "presentation": {   //控制终端显示
                "echo": false,  // 执行命令是否输出到集成终端
                "reveal": "always",
                "focus": false,
                "panel": "shared", //控制是否共享面板
                "showReuseMessage": false, //是否显示"终端终端将被重用,是否显示"的提示
                "clear": true  //执行任务前是否清除终端
            },
            //"problemMatcher": [],
            "group": {           
                "kind": "test", 
                "isDefault": true
            }
        }
    ]
}

(部分借鉴与网上的配置,配置完之后就可以Ctrl+F5 编译运行了,小伙伴们快试试吧)

上一篇下一篇

猜你喜欢

热点阅读