vscode使用外置终端
时间: 2023-10-29 16:57:56 浏览: 146
要在VSCode中使用外部终端C++调试,您需要进行以下配置。首先,在.vscode文件夹中的tasks.json文件中添加一个任务,以配置gcc的编译选项,并确保显示中文不会乱码。在tasks.json文件中添加以下代码:
```
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe 生成活动文件",
"command": "D:\\winGW\\mingw64\\bin\\gcc.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"-fexec-charset=GBK"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}
```
然后,您需要在调试中新建一个launch.json文件,并配置gdb调试器。在launch.json文件中添加以下代码:
```
{
"version": "0.2.0",
"configurations": [
{
"name": "gcc.exe - 生成和调试活动文件",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
阅读全文