launch.json 文件配置
{
"version": "0.2.0",
"configurations": [
{
"name": "gcc.exe build and debug active file",
"type": "cppdbg",
"request": "launch",
// "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"program": "${workspaceFolder}\\build\\${fileBasenameNoExtension}.exe", // 配置生成EXE文件路径,将EXE文件保存到单独的build文件夹
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "D:\\ProgramFile\\mingw64\\bin\\gdb.exe", // mingw64 安装位置
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "gcc.exe build active file"
}
]
}
tasks.json 文件配置
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "g++.exe build active file",
"command": "D:\\ProgramFile\\mingw64\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
// "${fileDirname}\\${fileBasenameNoExtension}.exe"
"${workspaceFolder}\\build\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "D:\\ProgramFile\\mingw64\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
vscode
settings.json文件 用于设置run code 快捷方式
该文件不在.vscode目录下 一般位于c盘 用户文件目录下 如 C:\Users\Administrator\AppData\Roaming\Code\User\settings.json
```
{
"code-runner.saveAllFilesBeforeRun": true,
"code-runner.runInTerminal": true,
"explorer.confirmDelete": false,
"code-runner.executorMap": {
"javascript": "node",
"python": "python",
"perl": "perl",
"go": "go run",
"c": "cd $dir && gcc $fileName -o $workspaceRoot/build/$fileNameWithoutExt && $workspaceRoot/build/$fileNameWithoutExt", // c 编译
"cpp": "cd $dir && g++ $fileName -o $workspaceRoot/build/$fileNameWithoutExt && $workspaceRoot/build/$fileNameWithoutExt", // c++ 编译
},
"workbench.iconTheme": "material-icon-theme",
"files.autoGuessEncoding": true,
"window.openFoldersInNewWindow": "on",
"python.autoComplete.addBrackets": true,
"workbench.colorTheme": "Visual Studio Light",
// "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
// "terminal.integrated.shellArgs.windows": [" chcp 65001 >nul"],
}
```
来源:博客园
作者:mchzys
链接:https://www.cnblogs.com/rsrm/p/11535759.html