zoukankan      html  css  js  c++  java
  • vs code 配置c/c++环境

    1. 编译

    通过 code-runner插件 运行编译

    安装code-runner后在settings.json中找到code-runner.executorMap,可以看到其中的cpp 文件运行方式为
    "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt"

    2. 调试

    c_cpp_properties.json: 这个文件现在的VScode版本已经不需要了

    task.json:

    {
        // See https://go.microsoft.com/fwlink/?LinkId=733558
        // for the documentation about the tasks.json format
        "version": "2.0.0",
        "command": "g++",
        "args": [
            "-g", 
            "-std=c++11", 
            // "${workspaceFolder}/${file}",
            // "${file}", 
            "${workspaceFolder}/${fileBasenameNoExtension}.cpp",
            "-o", 
            "${workspaceFolder}/${fileBasenameNoExtension}.o",
        ],// 编译命令参数
        "problemMatcher":{
            "owner": "cpp",
            "fileLocation":[
                "relative",
                "${workspaceFolder}/Documents"
            ],
            "pattern":[
                {
                    "regexp": "^([^\\s].*)\\((\\d+,\\d+)\\):\\s*(.*)$",
                    "file": 1,
                    "location": 2,
                    //"message": 3
                }
            ]
        },
        "group": {
            "kind": "build",
            "isDefault": true
        }
    }
    //"command": "g++",
    
    

    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": "${workspaceFolder}/${fileBasenameNoExtension}.o",
                "args": [],
                "stopAtEntry": false,
                "cwd": "${workspaceFolder}/Documents",
                "environment": [],
                "externalConsole": false,
                "MIMode": "gdb",
                "miDebuggerPath": "/usr/bin/gdb",
                "preLaunchTask": "g++",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            },
        ]
    }
    //"program": "${workspaceFolder}/${fileBasenameNoExtension}.o",
    //"cwd": "${workspaceFolder}",
    
    
  • 相关阅读:
    HTTP响应状态码记录
    Linux给指定用户或全部用户(已登录)发送消息
    JS面向对象的程序设计
    Linux下查看/管理当前登录用户及用户操作历史记录
    JS Math对象中一些小技巧
    Linux常用命令学习
    Python学习问题记录
    Python中dir()与help()的使用
    webdriver常用API
    数据库备份表
  • 原文地址:https://www.cnblogs.com/kolane/p/12051269.html
Copyright © 2011-2022 走看看