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
        }
    }
  }
需要注意的是 编译器的文件夹的名字一定不能随意改动,因为编译器连着编辑器,如果编译器的文件夹名字有变动,那么编辑器的后台所连接的编译器就会失效,就要重新把编译器的地址写进去

作者:Evinci

出处:https://www.cnblogs.com/evinci/p/17124015.html

版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。

posted @   EEvinci  阅读(21)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
more_horiz
keyboard_arrow_up light_mode palette
选择主题
menu
点击右上角即可分享
微信分享提示