vscode搭建c/c++环境

  1. 安装mingw64

2.vscode安装c/c++插件,run插件

3.在workspace/.vscode文件夹下新建三个文件:

1)c_cpp_properties.json

{

"configurations": [

{

"name": "Win32",

"includePath": [

"${workspaceFolder}/**"

],

"defines": [

"_DEBUG",

"UNICODE",

"_UNICODE"

],

"windowsSdkVersion": "10.0.17763.0",

"compilerPath": "E:\\mingw64\\bin\\g++.exe", /*bin目录下的g++.exe,两个反斜杠\\*/

"cStandard": "c11",

"cppStandard": "c++17",

"intelliSenseMode": "${default}"

}

],

"version": 4

}

2)launch.json

{

"version": "0.2.0",

"configurations": [

{

"name": "g++.exe build and debug active file",

"type": "cppdbg",

"request": "launch",

"program": "{fileDirname}\\\\build\\\\{fileBasenameNoExtension}.exe", /*收纳exe可执行文件*/

"args": [],

"stopAtEntry": false,

"cwd": "${workspaceFolder}",

"environment": [],

"externalConsole": true,

"MIMode": "gdb",

"miDebuggerPath": "E:\\mingw64\\bin\\gdb.exe", /*bin目录下的gdb.exe,两个反斜杠\\*/

"setupCommands": [

{

"description": "为 gdb 启用整齐打印",

"text": "-enable-pretty-printing",

"ignoreFailures": true

}

],

"preLaunchTask": "task g++"

}

]

}

3)tasks.json

{

"tasks": [

{

"type": "cppbuild",

"label": "C/C++: g++.exe 生成活动文件",

"command": "E:\\mingw64\\bin\\g++.exe",

"args": [

"-fdiagnostics-color=always",

"-g",

"${file}",

"-o",

"{fileDirname}\\\\{fileBasenameNoExtension}.exe"

],

"options": {

"cwd": "${fileDirname}"

},

"problemMatcher": [

"$gcc"

],

"group": {

"kind": "build",

"isDefault": true

},

"detail": "调试器生成的任务。"

}

],

"version": "2.0.0"

}

注意:这里三个文件 关于是mingw的安装位置,要根据自己的安装位置修改一下

相关推荐
bkspiderx11 分钟前
C/C++中float浮点型的存储方式与使用要点
c++
haiyu柠檬34 分钟前
IDEA和VSCode中好用的插件推荐
java·vscode·intellij-idea
起个名字费劲死了1 小时前
QT + Socket 客户端/服务端 公网通讯
服务器·c++·qt·socket
我是一只小青蛙8881 小时前
位图与布隆过滤器:高效数据结构解析
开发语言·c++·算法
xiaoye-duck1 小时前
吃透C++类和对象(下):初始化列表深度解析
c++
曼巴UE52 小时前
UE5 C++ GameInstanceSubsystem 在学习
c++·ue5·ue
Ethan Wilson2 小时前
VS2019 C++20 模块相关 C1001: 内部编译器错误
开发语言·c++·c++20
m0_748252382 小时前
Bootstrap 5 加载效果实现方法
c++
wzfj123453 小时前
vscode 安装 Serial Monitor 扩展
vscode·serial
人工智能AI技术3 小时前
GitHub Copilot 2026新功能实操:C++跨文件上下文感知开发,效率翻倍技巧
c++·人工智能