Daniel H Sagarra
Daniel H Sagarra

Reputation: 180

Visual Studio Code highlight warring c c++

I've got confused about how to configure VS Code to show warnings, in my system:

// C code:

#include <stdio.h>

int main()
{
    int a;
    printf("%d", a);
  
}

In this case, I should get: 'a' is used uninitialized, how I can get all warnings?

Upvotes: 1

Views: 1528

Answers (1)

Daniel H Sagarra
Daniel H Sagarra

Reputation: 180

I found the answer, Add "-Wall" in the file task.json located in the folder .vscode If the file task.json is not automatically generated by VS Code you can add it manually:

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: gcc.exe build active file",
            "command": "C:\\msys64\\mingw64\\bin\\gcc.exe",
            "args": [
                "-Wall",
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

enter image description here

Upvotes: 2

Related Questions