【问题标题】:Visual studio code, compiling and running in single commandVisual Studio 代码,在单个命令中编译和运行
【发布时间】:2016-11-03 17:10:30
【问题描述】:

我已经指定了一个启动前任务来编译 c++ 代码,然后在 launch.json 文件中启动。

我的 tasks.json 文件中概述了构建命令:

"version": "0.1.0",
"command": "bash",
"isShellCommand": true,
"args": ["-c"],
"showOutput": "always",
"tasks": [
    {
        "taskName": "g++",
        "isBuildCommand": true,
        "args": [
            "g++ /Users/user/OneDrive/Programming/TicTacToe/TicTacToe.cpp -o /Users/user/OneDrive/Programming/TicTacToe/a.out"
        ],
        "showOutput": "always"
    }
]

当我运行它时的输出是我收到一个 clang 错误:

clang: error: no input files

我不确定为什么会发生这种情况,因为当我将此 bash 命令复制粘贴到终端时它可以工作,但由于某种原因,我从 Visual Studio 收到了 clang 错误。任何熟悉 clang 的人都可以弄清楚这里出了什么问题吗?

【问题讨论】:

    标签: c++ json bash clang visual-studio-code


    【解决方案1】:

    问题是由于某种原因传递的字符串包含任务名称。

    我添加后它起作用了

    "suppressTaskName": true
    

    到tasks.json

    【讨论】:

      猜你喜欢
      • 2011-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-16
      相关资源
      最近更新 更多