• vscode linux c++ 配置


    简介

    最官方的配置方案 https://code.visualstudio.com/docs/cpp/config-linux

    有三个文件会生成

    tasks.json (编译器构建设置)
    launch.json (调试器设置)
    c_cpp_properties.json (编译器路径和IntelliSense设置)

    三个文件的配置命令

    tasks.json

    Terminal > Configure Default Build Task
    选择 C/C++: g++ build active file

    lauch.json

    Run > Add Configuration... and then choose C++ (GDB/LLDB).
    选择 Choose g++ build and debug active file.

    c_cpp_properties.json

    ctrl + shift + p 打开命令行 输入 c/c++
    选择带有 ui 的那个
    C/C++: Edit Configurations (UI)

    复用配置文件

    VS Code现在已配置为在Linux上使用gcc。该配置适用于当前工作空间。要重用配置,只需将JSON文件复制到.vscode新项目文件夹(工作区)中的文件夹中,然后根据需要更改源文件和可执行文件的名称。

    tasks.json

    {
        "version": "2.0.0",
        "tasks": [
            {
                "type": "shell",
                "label": "C/C++: g++ build active file",
                "command": "/usr/bin/g++",
                "args": [
                    "-g",
                    "${file}",
                    "-o",
                    "${fileDirname}/${fileBasenameNoExtension}"
                ],
                "options": {
                    "cwd": "/usr/bin"
                },
                "problemMatcher": [
                    "$gcc"
                ],
                "group": {
                    "kind": "build",
                    "isDefault": true
                }
            },
            {
                "type": "shell",
                "label": "g++ build active file",
                "command": "/usr/bin/g++",
                "args": [
                    "-g",
                    "${file}",
                    "-o",
                    "${fileDirname}/${fileBasenameNoExtension}"
                ],
                "options": {
                    "cwd": "/usr/bin"
                }
            }
        ]
    }
    

    lauch.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": "调试",
                "type": "cppdbg",
                "request": "launch",
                "program": "${fileDirname}/bin/${fileBasenameNoExtension}",
                "args": ["-p", "3", "4", "5", "6"],
                "stopAtEntry": false,
                "cwd": "\",
                "environment": [],
                "externalConsole": false,
                "MIMode": "gdb",
                "setupCommands": [
                    {
                        "description": "为 gdb 启用整齐打印",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            },
            {
                "name": "clang - 生成和调试",
                "type": "cppdbg",
                "request": "launch",
                "program": "${fileDirname}/bin/${fileBasenameNoExtension}", // 可以改成绝对路径
                "args": ["-p", "3"],
                "stopAtEntry": false,
                "cwd": "${workspaceFolder}",
                "environment": [],
                "externalConsole": false,
                "MIMode": "gdb",
                "setupCommands": [
                    {
                        "description": "为 gdb 启用整齐打印",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ],
                "preLaunchTask": "clang build active file",
                "miDebuggerPath": "/usr/bin/gdb"
            }
        ]
    }
    
    

    c_cpp_properties.json

    {
        "configurations": [
            {
                "name": "Linux",
                "includePath": [
                    "${workspaceFolder}/**"
                ],
                "defines": [],
                "compilerPath": "/usr/bin/gcc",
                "cStandard": "c11",
                "cppStandard": "c++17",
                "intelliSenseMode": "clang-x64"
            }
        ],
        "version": 4
    }
    
    Hope is a good thing,maybe the best of things,and no good thing ever dies.----------- Andy Dufresne
  • 相关阅读:
    KVO的用法、底层实现原理
    Runtime应用(三)实现NSCoding的自动归档和自动解档
    Runtime应用(二)使用对象关联为分类增加属性(每个对象的属性互不干扰)
    Runtime 应用(一)拦截系统自带的方法交换实现
    iOS实现传递不定长的多个参数
    Runtime 中的 _cmd、 IMP
    UIWebView、WKWebView使用详解及性能分析
    iOS
    基本图形生成算法
    关于动画中帧的解释
  • 原文地址:https://www.cnblogs.com/eat-too-much/p/12840847.html
Copyright © 2020-2023  润新知