【发布时间】:2021-10-31 10:25:02
【问题描述】:
我正在尝试在 Windows 10 上使用 vscode 构建和运行 C 代码。
我浏览了vscode doc for mingw configuration,按照那里的步骤并设法使用 vscode 运行了一个 .c 文件。
但是,还有一个问题。
每次通过“Run | Run without Debugging”运行我的程序时,面板会自动切换到“TERMINAL”
所以每次运行代码都得手动切换到DEBUG CONSOLE,很乏味。
有没有办法让“DEBUG CONSOLE”面板保持活动状态或在“TERMINAL”面板中显示我的程序输出
我也在另一个stackoverflow post 中尝试过这个建议,但它对我不起作用。
tasks.json
这是我的 tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe build active file",
"command": "E:\\MinGW\\bin\\gcc.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: E:\\MinGW\\bin\\gcc.exe"
}
]
}
launch.json
这是我的 launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "gcc.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "E:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe build active file"
}
]
}
如何使 vs code 将我的 c 程序的输出放在 TERMINAL 面板中?
【问题讨论】: