【问题标题】:VS code - Hide build/echo task for cppVS 代码 - 隐藏 cpp 的构建/回显任务
【发布时间】:2022-01-14 11:03:43
【问题描述】:

我正在使用 VS Code 来运行 c++ 代码。

每当我 Ctrl + Shift + B 构建我的 .cpp 文件时,都会弹出一个“回显”选项卡,这会使整个底部面板出现,然后我被要求“终端将被任务重用,按任何关闭它的键。"

我不希望标签或面板弹出根本,并希望整个构建过程在静默中发生,什么都不会弹出。

这是我的 tasks.json 文件

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
    {
        "label": "echo",
        "type": "shell",
        "command": "gcc",
        "args":[
            "main.cpp","-lstdc++","-o" ,"main.exe"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        }
    }
]

}

【问题讨论】:

  • 可能跑题了,但你不需要-lstdc++,因为它是默认的,除非你使用-nodefaultlibs和另一个c++标准库,比如clang的-llibc++
  • 你应该使用g++来编译C++代码,而不是gcc
  • 我需要包含 -lstdc++,因为我使用包含 启动我的 cpp 代码。我不确定使用 gcc 和 g++ 编译之间的区别,但到目前为止,这两个选项对我来说都很好。
  • 如果您使用g++,则不需要-lstdc++(更正确)。

标签: c++ visual-studio-code terminal build


【解决方案1】:

这可以使用"presentation": {...} 进行配置。以下对我有用:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Test task",
            "type": "shell",
            "command": "echo Hello world",
            "presentation": {
                "echo": true,
                "reveal": "never",
                "showReuseMessage": false,
            }
        }
    ]
}

【讨论】:

  • 非常感谢!
  • @NguyenKhacKhanhLam 不客气!您可以按答案旁边的复选标记,将您的问题标记为已解决。
【解决方案2】:

通过将 VSCode 降级到 1.60 解决:https://code.visualstudio.com/updates/v1_60

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-10-19
    • 1970-01-01
    • 1970-01-01
    • 2019-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多