visual studio代码调试C请求超时



我正在测试VS代码的调试功能。这是我的测试代码:

#include <stdio.h>
int d=100;
int x=200;
int main() 
{  
printf("d=%d,x=%dn",d,x);
return 0;
}

这是我在.vscode:中的launch.json

{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/main",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}

我按了F5,等了很长时间,但它没有反应保持此状态:在此处输入图像描述

很长一段时间后,会出现一个对话框,上面写着"请求超时"。

调试功能以前在我的机器上运行得很好。但我不知道为什么它现在不起作用。有人告诉我这里有什么问题吗?

PS:我已经安装了C/C++扩展,并在编译时打开了"-g"标志。

我解决了这个问题,只需将launch.json中的"externalConsole"从true更改为false,尽管我不知道为什么。如果有人能解释一下,我会很高兴的。

最新更新