前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >专栏 >Visual Studio Code C++配置文件

Visual Studio Code C++配置文件

作者头像
Michael阿明
发布2022-01-07 11:39:23
发布2022-01-07 11:39:23
1.2K00
代码可运行
举报
运行总次数:0
代码可运行

文章目录

以下三个文件放在 项目下 .vscode 文件夹中,内容从网络收集,经自己实践添加修改以备忘

tasks.json

代码语言:javascript
代码运行次数:0
运行
复制
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    // tasks.json这个文件是定义调试开始前要执行的任务,即(或者绝大多数是)编译程序, 
    // 定义了用于编译程序的编译器,所输出的文件格式,使用的语言标准等
    // 下载mingw-w64 https://www.mingw-w64.org/downloads/
    "version": "2.0.0",
    "tasks": [
        {
            "label": "g++编译",
            "command": "C:/mingw/bin/g++.exe", // 根据自己的路径修改,记得添加bin路径到path环境变量
            "args": [
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}.exe",
                "-g",
                "-static-libgcc",
                "-fdiagnostics-color=always",
                "-std=c++14" // 如果c++17报错,可能编译器不支持,尝试降低版本
            ],
            "type": "shell",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": true,
                "panel": "shared"
            },
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
        },
        
    ]
}

launch.json

代码语言:javascript
代码运行次数:0
运行
复制
{  
    "version": "0.2.0",  
    "configurations": [  
        {  
            "name": "(gdb) Launch", // 配置名称,将会在启动配置的下拉菜单中显示  
            "type": "cppdbg",       // 配置类型,这里只能为cppdbg  
            "request": "launch",    // 请求配置类型,可以为launch(启动)或attach(附加)  
            "program": "${fileDirname}/${fileBasenameNoExtension}.exe",// 将要进行调试的程序的路径  
            "args": [],             // 程序调试时传递给程序的命令行参数,一般设为空即可  
            "stopAtEntry": false,   // 设为true时程序将暂停在程序入口处,一般设置为false  
            "cwd": "${fileDirname}", // 调试程序时的工作目录,一般为${fileDirname}即代码所在目录  
            "environment": [],  
            "externalConsole": false, // 调试时是否显示控制台窗口
            "MIMode": "gdb",  
            "miDebuggerPath": "C:/mingw/bin/gdb.exe", // miDebugger的路径,注意这里要与MinGw的路径对应  
            "preLaunchTask": "g++编译", // 跟 tasks.json 的 label 字段一致
            "setupCommands": [  
                {   
		            "description": "Enable pretty-printing for gdb",  
                    "text": "-enable-pretty-printing",  
                    "ignoreFailures": true  
                }  
            ]  
        }  
    ]  
}

c_cpp_properties.json

代码语言:javascript
代码运行次数:0
运行
复制
{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:/mingw/include/*" // 根据自己的需要添加多个
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:/mingw/bin/gcc.exe", // 修改为自己的路径
            "cStandard": "c11",
            "cppStandard": "c++14", // 如果c++17报错,可能编译器不支持,尝试降低版本
            "intelliSenseMode": "gcc-x64"
        }
    ],
    "version": 4
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021/10/15 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 文章目录
  • tasks.json
  • launch.json
  • c_cpp_properties.json
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档