【问题标题】:How to show gcc compiler warnings in VSCode terminal of a .c file如何在 .c 文件的 VSCode 终端中显示 gcc 编译器警告
【发布时间】:2021-04-20 09:00:45
【问题描述】:

我安装了 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 选项。 当我编译并运行代码时,警告不会出现在我的终端中,只会出现错误。 我错过了什么吗?

【问题讨论】:

    标签: linux gcc visual-studio-code vscode-settings vscode-tasks


    【解决方案1】:

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

    "code-runner.executorMap": {
    
        ...
        "c": "cd $dir && gcc -Wall $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        ...
    

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

    【讨论】:

      猜你喜欢
      • 2020-07-07
      • 1970-01-01
      • 2020-03-15
      • 1970-01-01
      • 1970-01-01
      • 2021-06-09
      • 1970-01-01
      • 1970-01-01
      • 2016-07-30
      相关资源
      最近更新 更多