我在 Visual Studio 代码中的 ubuntu 上创建了一个 c++ 项目。它使用 gdb 模式启动程序,但在输出中不显示任何内容。当我从控制台启动程序时,输出存在。我尝试插入“控制台”属性,但 vscode 告诉我,这是被禁止的(来自节点 https://github.com/Microsoft/vscode/issues/30842 的类似问题)。
如何启用 vscode 以显示我的程序的输出?
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
原文由 Rob Yart 发布,翻译遵循 CC BY-SA 4.0 许可协议
你的配置是正确的。程序输出应该在 DEBUG CONSOLE 中。
菜单 |调试控制台 或 Ctrl+Shift+Y 。