Jak zrobić aby VScode pokazywał warning ?

0

Używam Visual Studio Code, tak wygląda mój launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++ - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [
                "-g",
                "-o",
                "main",
                "main.cpp",
                "-Wall",
                "-static",
                "-Wextra",
                "-Wshadow",
                "-Wconversion",
                "-O3",
                "-Wunreachable-code",
                "-Wswitch-default"
            ],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++ build active file",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}

Po kompilacji pokazuje tylko problemy które uniemożliwiają skompilowanie programu, ale nigdzie nie potrafię znaleźć Warnings, lub opcji pokazujące je, proszę o pomoc :)

0

Dodaj do "args" parameter -Werror to ostrzeżenia staną się błędami kompilacji.

0

Wkleiłem ale to nie pomaga, kompiluje taki program:

#include <bits/stdc++.h>

using namespace std;

int funkcja_ktora_powoduje_warning(){
    int x = 2137;
    //powinienem zwracac int a nie zwracam nic, wiec powinien pojawic sie warning
}

int main(){
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(NULL);
    funkcja_ktora_powoduje_warning();

    return 0;
}

launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++ - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [
                "-g",
                "-o",
                "main",
                "main.cpp",
                "-Wall",
                "-static",
                "-Wextra",
                "-Wshadow",
                "-Wconversion",
                "-O3",
                "-Wunreachable-code",
                "-Wswitch-default",
                "-Werror"
            ],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++ build active file",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}

tasks.json

{
    "version": "2.0.0",
    "configurations": [
      {
        "name": "g++ build and debug active file",
        "type": "cppdbg",
        "request": "launch",
        "program": "${fileDirname}/${fileBasenameNoExtension}",
        "args": [
            "-Werror"
        ],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": false,
        "MIMode": "gdb",
        "setupCommands": [
          {
            "description": "Enable pretty-printing for gdb",
            "text": "-enable-pretty-printing",
            "ignoreFailures": true
          }
        ],
        "preLaunchTask": "g++ build active file",
        "miDebuggerPath": "/usr/bin/gdb"
      }
    ]
  }

settings.json

{
    "files.associations": {
        "valarray": "cpp"
    }
}

Ale zauważyłem że jak klikam "Run and debbug" to przez chwilkę pojawia się ten warning a później znika, jakby vscode sam go zamykał

0

Mi jakis taki tasks.json wygenerowal

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: clang++ build active file",
            "command": "/usr/bin/clang++",
            "args": [
                "-g",
                "-Wall",
                "-Wextra",
                "-Wshadow",
                "-O2",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "/usr/bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "Generated task by Debugger"
        },
        {
            "type": "cppbuild",
            "label": "C/C++: g++ build active file",
            "command": "/usr/bin/g++",
            "args": [
                "-g",
                "-Wall",
                "-Wextra",
                "-Wshadow",
                "-O2",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "/usr/bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "Generated task by Debugger"
        },
        {
            "type": "cppbuild",
            "label": "C/C++: cpp build active file",
            "command": "/usr/bin/cpp",
            "args": [
                "-g",
                "-Wall",
                "-Wextra",
                "-Wshadow",
                "-O2",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "/usr/bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Generated task by Debugger"
        }
    ],
    "version": "2.0.0"
}
0

Nie miałem zrobionego c_cpp_properties.json, jak go zrobiłem i spróbowałem uruchomić to pokazuje się wszystko, ale teraz daje error że nie nie potrafi znaleźć biblioteki <iostream> mógłbyś zobaczyć co mam tutaj źle?

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/g++",
            "cStandard": "gnu11",
            "cppStandard": "gnu++14",
            "intelliSenseMode": "gcc-x64",
            "compilerArgs": [
                "-g",
                "-Wall",
                "-Wextra",
                "-Wshadow",
                "-O2",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ]
        }
    ],
    "version": 4
}

EDIT:
Które powinienem wybrać?Screenshot from 2020-12-08 18-04-22.png

1 użytkowników online, w tym zalogowanych: 0, gości: 1