如何在 .c 文件的 VSCode 终端中显示 gcc 编译器警告

How to show gcc compiler warnings in VSCode terminal of a .c file

我安装了 C/C++ ms-vscode.cpptools 扩展(和 Code Runner)。 这是我的 task.json

"version": "2.0.0",
"tasks": [
    {
        "type": "cppbuild",
        "label": "C/C++: gcc build active file",
        "command": "/usr/bin/gcc",
        "args": [
            "-g",
            "-Wall",
            "${file}",
            "-o",
            "${fileDirname}/${fileBasenameNoExtension}"
        ],
        "options": {
            "cwd": "${workspaceFolder}"
        },
        "problemMatcher": [
            "$gcc"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "detail": "compiler: /usr/bin/gcc"
    }
]

注意 args 部分中的 -Wall 选项。 当我编译和 运行 代码时,警告不会显示在我的终端中,只有错误。 我错过了什么吗?

解决了代码运行器的配置也要被编辑。

"code-runner.executorMap": {

    ...
    "c": "cd $dir && gcc -Wall $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    ...

现在,如果我通过 VSCode 和代码运行器构建,我会显示警告。