安装VS Code
安装Mingw-w64
安装C/C++支持插件
配置
pip install -U 重新安装
打开你的.c文件在的文件夹,点击添加配置
别选bash,选其他的gdb或Windows启动,launch.json的配置
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(Windows) 启动",
"type": "cppvsdbg",
"request": "launch",
"program": "输入程序名称,例如 ${workspaceFolder}/a.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false
},
{
"name": "(gdb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/interp2.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:/MinGW/bin/gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe build active file"
},
{
"name": "Python: 当前文件",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
注意:“preLaunchTask”: "C/C++: gcc.exe build active file"是我特地加进去的。从task.json中的“label当中直接拷贝”
配置task.json文件
随之则会生成一个tasks.json的文件
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe build active file",
"command": "C:/MinGW/bin/gcc.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "C:/MinGW/bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "compiler: C:/MinGW/bin/gcc.exe"
}
]
}
基本上都一样,不用改
c/c++配置
然后ctrl+shift+p打开命令输入edit configurations,自动建立c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:/MinGW/include",
"c:/mingw/bin/../lib/gcc/mingw32/9.2.0/include",
"c:/mingw/bin/../lib/gcc/mingw32/9.2.0/../../../../include",
"D:\\Python\\Python37\\include",
"c:/mingw/bin/../lib/gcc/mingw32/9.2.0/include-fixed"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"cStandard": "gnu11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
基本上也不用改
最后就可以打断点运行了