首页  >  问答  >  正文

visual-studio-code - vscode配置c/c++怎么让编译之后立刻运行?

只是想编译之后立刻运行,像sublime那样从文件读入后输出到下面控制台。
写了个tasks.json

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "0.1.0",
    "tasks": [
        {
            "taskName": "build",
            "command": "g++",
            "isShellCommand": true,
            "args": [
                "-o",
                "${workspaceRoot}/main",
                "${workspaceRoot}/main.cpp"
            ],
            "showOutput": "always"
        },
        {
            "taskName": "run",
            "command": "${workspaceRoot}/main",
            "isShellCommand": true,
            "showOutput": "always"
        }
    ]
}

为啥,第二个任务不会运行。。

高洛峰高洛峰2714 天前578

全部回复(1)我来回复

  • 天蓬老师

    天蓬老师2017-04-17 15:27:32

    现在VS Code的任务是不会连续执行的。

    解决方法:

    1. 利用外部工具,例如写脚本、msbuild、make等等

    2. 配置调试,不加断点,编译后再按F5运行

    2017-03-02更新:

    VS Code 1.10支持组合多个任务了,也可以给单个任务设快捷键。

    回复
    0
  • 取消回复