简介

  • VSCode下C++程序的调试的配置文件是launch.json。这篇文章是关于launch.json文件的使用笔记,包括常见的参数,常用技巧和常见错误及其解决方法。

windows 程序调试阻塞,出现 unable to start Microsoft Visual Debug Console.

  • 这个是因为程序输出需要在命令窗口中,在launch.json中console参数是设置命令窗口的启动属性。如果设置了 externalTerminal 则会出现问题。

  • 解决方法

    • 将console的值设置为 integratedTerminal

console 参数 详解

  • console: Where to launch the debug target. Defaults to ‘internalConsole’ if not defined.
  • console: 需要调试的程序运行的地方。如果没有定义,默认为 internalConsole

  • console的值有:
    • externalTerminal:
      • Console applications will be launched in an external terminal window. The window will be reused in relaunch scenarios and will not automatically disappear when the application exits.
      • 控制台应用程序将在外部控制台窗口中启动。这个窗口将在程序再次启动时被重复使用,并且不会随着程序退出自动退出。
    • integratedTerminal
      • VS Code’s integrated terminal.
      • VSCode的集成终端
    • internalConsole
      • Output to the VS Code Debug Console. This doesn’t support reading console input (ex:’std::cin’ or ‘scanf’).
      • 输出到VSCode调试窗口。这个不支持从窗口读取数据,例如 std::cin或 scanf
    • newExternalWindow
      • Console applications will be launched in their own external console window which will end when the application stops. Non-console applications will run without a terminal, and stdout/stderr will be ignored.
      • 控制台应用程序将在其自己的外部控制台窗口中启动,该窗口将在应用程序停止时结束。非控制台应用程序在没有终端且标准输出和标准错误输出被忽略的情况下运行。