Loading

VScode配置C/C++环境

vscode写C语言

环境配置

三个函数

一、c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "/usr/include",
                "/usr/local/include",
                "${workspaceRoot}"
            ],
            "defines": [],
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [
                    "/usr/include",
                    "/usr/local/include",
                    "${workspaceRoot}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "macFrameworkPath": [
                "/System/Library/Frameworks",
                "/Library/Frameworks"
            ],
            "compilerPath": "D:\\Software\\mingw64\\bin\\gcc.exe",
            "cStandard": "c11",
            "cppStandard": "gnu++14"
        },
        {
            "name": "Linux",
            "includePath": [
                "/usr/include",
                "/usr/local/include",
                "${workspaceRoot}"
            ],
            "defines": [],
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [
                    "/usr/include",
                    "/usr/local/include",
                    "${workspaceRoot}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "compilerPath": "E:\\MinGw\\mingw64\\bin\\gcc.exe",
            "cStandard": "c11",
            "cppStandard": "gnu++14"
        },
        {
            "name": "Win32",
            "includePath": [
            //电脑中安装的路径
                "E:/MinGw/mingw64/include",
                "${workspaceRoot}"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE"
            ],
            "intelliSenseMode": "gcc-x64",
            "browse": {
                "path": [
                //电脑中安装的路径
                    "E:/MinGw/mingw64/include",
                    "${workspaceRoot}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            //电脑中安装的路径
            "compilerPath": "E:\\MinGw\\mingw64\\bin\\gcc.exe",
            "cStandard": "c11",
            "cppStandard": "gnu++14"
        }
    ],
    "version": 4
}

二、launch.json

    "version": "0.2.0",
    "configurations": [
  
        {
            "name": "(gdb)c_launch",
            "type": "cppdbg",
            "request": "launch",
            "targetArchitecture": "x64",
            "program": "${workspaceFolder}/${fileBasenameNoExtension}.exe",
            //替换电脑中的路径
            "miDebuggerPath": "E:/MinGw/mingw64/bin/gdb.exe",
            "MIMode": "gdb",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "internalConsoleOptions": "openOnFirstSessionStart",
            "externalConsole": true,
            "preLaunchTask": "gcc"
        }
    ]
  }

三、tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "command": "gcc",
    "args": ["-Wall", "-g", "${file}", "-o", "${fileBasenameNoExtension}.exe"],
    "echoCommand": true,
    "problemMatcher": {
        "owner": "cpp",
        "fileLocation": ["relative", "${workspaceFolder}"],
        "pattern": {
            "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
            "file": 1,
            "line": 2,
            "column": 3,
            "severity": 4,
            "message": 5
        }
    }
  }
需要注意的是 编译器的文件夹的名字一定不能随意改动,因为编译器连着编辑器,如果编译器的文件夹名字有变动,那么编辑器的后台所连接的编译器就会失效,就要重新把编译器的地址写进去
posted @ 2021-10-18 19:14  EEvinci  阅读(17)  评论(0编辑  收藏  举报