首页 > 解决方案 > Visual Studio 代码调试 C 请求超时

问题描述

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

#include <stdio.h>
int d=100;
int x=200;
int main() 
{  
    printf("d=%d,x=%d\n",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,等了好久,没有反应,一直停留在这个状态: enter image description here

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

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

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

标签: cdebuggingvisual-studio-code

解决方案


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


推荐阅读