Skip to content
Advertisement

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

I have the C/C++ ms-vscode.cpptools extension installed (and the Code Runner). This is my 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"
    }
]

Note the -Wall option in the args part. When I compile and run the code the warnings don’t show up in my terminal, the errors only. Am I missing something?

Advertisement

Answer

Solved it was the configuration of code runner to be edited as well.

"code-runner.executorMap": {

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

Now if I build via VSCode and via code runner I have my warnings displayed.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement