tasks.json、launch.json、c_cpp_properties.json配置

tasks.json

json 复制代码
//tasks.json是辅助程序编译的模块,执行类似于在命令行输入"gcc hello.c -o hello"命令的操作
{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "cppbuild",                                //任务类型(如果是shell,下面的command就相当于执行shell命令)
			"label": "task g++",                               //任务的名称,可以修改,但一定要和launch.json的"preLaunchTask"项保持一致
			"command": "F:\\exe\\mingw64\\bin\\g++.exe",       //编译器的路径
			"args": [                                          //(常用)编译时使用的参数,和命令行下相同
				"-fdiagnostics-color=always",
				"-g",
				"${file}",
				"-o",
				"${fileDirname}\\${fileBasenameNoExtension}.exe",
				"-fexec-charset=GBK",                         //中文乱码
				"-std=c++17"
			],
			"options": {
				"cwd": "${fileDirname}"                       //编译的目录
			},
			"problemMatcher": [                               //使用gcc捕捉错误
				"$gcc"
			],
            "group": {
                "kind": "build",
                "isDefault": true
            },
			"detail": "编译器: F:\\exe\\mingw64\\bin\\g++.exe"   //一些描述性信息
		}
	]
}

launch.json

json 复制代码
{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        // {
        //     "type": "node",
        //     "request": "launch",
        //     "name": "Launch Program",
        //     "skipFiles": [
        //         "<node_internals>/**"
        //     ],
        //     "program": "${file}"
        // },
        {
            "name": "运行和调试",                  //运行和调试任务的名称,可自定义
            "type": "cppdbg",                     //配置类型,默认即可
            "request": "launch",                  //launch模式允许我们打断点进行调试,默认即可
            "program": "${fileDirname}/${fileBasenameNoExtension}.exe",    //(常用)将要执行调试的程序的路径
            "args": [],                           //(常用)程序(main函数)的入口参数
            "stopAtEntry": false,                 //在入口处暂停,选true相当于在入口处增加断点
            "cwd": "${workspaceFolder}",          //程序调试时的工作目录
            "environment": [],                    //添加到程序的环境变量
            "externalConsole": false,             //true在调试时会开启系统控制台窗口,false会使用vscode自带的调试控制台
            "MIMode": "gdb",                      //使用gdb进行调试
            "setupCommands": [                    //用来设置gdb的参数,默认即可
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "task g++",                      //(常用)运行和调试前要执行的task(编译)任务,任务名要和task.json里的"label"对应
            "miDebuggerPath": "F:/exe/mingw64/bin/gdb.exe"       //debug调试工具的路径,这里使用gdb所在的路径
        }
    ]
}

c_cpp_properties.json

json 复制代码
//c_cpp_properties.json主要用来设置包含头文件的路径,设置C/C++支持的版本号等。
{
    "configurations": [
        {
            "name": "Win32",                 //配置名称,默认为系统名,可以自行更改
            "includePath": [                 //(常用)运行项目包含.h头文件的目录

                /**
                    ${workspaceFolder}          : vs code当前打开工作区文件夹的路径
                    ${file}                     : 当前打开文件的绝对路径
                    ${fileBasename}             : 当前打开文件的名称
                    ${fileBasenameNoExtension}  : 当前打开文件的名称,但是不加后缀名
                    ${fileDirname}              : 文件所在的文件夹路径
                */
                "${workspaceFolder}/**"      //此处会匹配工作文件下的所有文件
                //ming64路径
                // "F:/exe/mingw64/include/**",
                // "F:/exe/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../include",

                // "F:/exe/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++",
                // "F:/exe/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32",
                // "F:/exe/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward",
                // "F:/exe/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include",
                // "F:/exe/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed"
            ],
            "defines": [                    //(常用)定义一些需要的变量,等价于在编译时写"-D变量"
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "F:\\exe\\mingw64\\bin\\g++.exe",    //编译器的路径
            "cStandard": "c11",                                  //C标准的版本
            "cppStandard": "c++17",                              //C++标准的版本
            "intelliSenseMode": "windows-gcc-x64"                //IntelliSence的一些配置,默认即可
        }
    ],
    "version": 4
}

推荐内容:

https://blog.csdn.net/m0_70885101/article/details/131154332
https://blog.csdn.net/Zhouzi_heng/article/details/115014059
https://www.cnblogs.com/harrypotterisdead/p/14207866.html

相关推荐
毕设木哥1 分钟前
25届计算机专业毕设选题推荐-基于python的二手电子设备交易平台【源码+文档+讲解】
开发语言·python·计算机·django·毕业设计·课程设计·毕设
珞瑜·1 分钟前
Matlab R2024B软件安装教程
开发语言·matlab
weixin_455446172 分钟前
Python学习的主要知识框架
开发语言·python·学习
孤寂大仙v7 分钟前
【C++】STL----list常见用法
开发语言·c++·list
她似晚风般温柔7891 小时前
Uniapp + Vue3 + Vite +Uview + Pinia 分商家实现购物车功能(最新附源码保姆级)
开发语言·javascript·uni-app
咩咩大主教1 小时前
C++基于select和epoll的TCP服务器
linux·服务器·c语言·开发语言·c++·tcp/ip·io多路复用
时光飞逝的日子1 小时前
多重指针变量(n重指针变量)实例分析
c语言·指针·多重指针·双重指针·n重指针·指针变量
FuLLovers2 小时前
2024-09-13 冯诺依曼体系结构 OS管理 进程
linux·开发语言
everyStudy2 小时前
JS中判断字符串中是否包含指定字符
开发语言·前端·javascript
luthane3 小时前
python 实现average mean平均数算法
开发语言·python·算法