小编Fil*_*ris的帖子

[Visual Studio Code]:保存时运行任务

我想用 vscode 开发 C 程序。

如果我理解正确的话, Mytasks.json描述了构建阶段,如下所示:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "C/C++: gcc build active file",
            "command": "/usr/bin/gcc",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "runOptions": {
                "runOn": "default"
            }
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

由于所有编译器错误都是由构建生成的,因此我想在每次保存文件时运行它。这使我能够立即获得编译器反馈。

我该如何设置这个?请注意,大多数插件(例如“保存时运行”)不起作用,因为我无法指定任务,只能指定命令,然后我不会收到编译器错误。

c build visual-studio-code vscode-tasks

8
推荐指数
1
解决办法
4758
查看次数

标签 统计

build ×1

c ×1

visual-studio-code ×1

vscode-tasks ×1