How to enabled build warnings?

Hi all, I am new here.

I am using platformio/VSCode on windows with the Arduino framework and an Arduino Nano Every board. When I compile the program below in the Arduino IDE it gives me correctly a warning that variable a is used without being initialized. However, when I compile it under platformio, even with verbose build, I don’t get any warning.

How do I enable the build warnings under platformio? My platformio.ini file is below

// Sample program
    void setup() {
    }
    static volatile int c;
    void loop() {
      int a;
      c += a;
    }

// platformio.ini
    [env:nano_every]
    platform = atmelmegaavr
    board = nano_every
    framework = arduino
    lib_extra_dirs = ~/Documents/Arduino/libraries
    monitor_speed = 115200
    build_flags = 
        -UAVR_NANO_4809_328MODE
        -Wall
        -Wextra
        -Werror
        -Wunused-variable

Edit: the warning is reported by the platformio ‘check’ function but I don’t run it as often as the BUILD.

Actually I cannot make the compiler that is being used here (AVR-G++ 7.3.0) output a warning for this piece of code, even with all these build flags (plus -Wuninitialized):

Reading up on some stackoverflow post indicates that this might a bug which is present in some GCC versions.

I have also let the AVR-G++ compiler that is used in the Arduino IDE for the Nano Every board compile it (it’s in C:\Users\<user>\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7\bin for me), and it also doesn’t throw an error (also not in the Arduino IDE window). And that was on the “Arduino megaAVR Boards” package version 1.8.4. Newest is 1.8.6.

Even after after updating to 1.8.6, no error appears. Also no other toolchain version is installed. Sketch compilation goes through without errors

So, can you show a screenshot of the Arduino IDE board manager regarding the megaAVR pacakge?

Hi @maxgerhardt, you can find here C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -ha - Pastebin.com a full log of my build under the Android IDE. Notice the warning : warning: ‘a’ is used uninitialized in this function [-Wuninitialized]

I am using Android IDE 1.8.13 on Windows 10.

Is this the information you asked for?

No I need

that’s found in the Tools -> Board -> Board manager section

@maxgerhardt, is this what you are looking for?

image

I’m using the same package version and yet no warning appears. Can you show a screenshot of the Arduino IDE where the warning appears together with the code?

@maxgerhardt, here is the screenshot. (If you will open the image in a new browser tab text will be more readable)

image

I still didn’t figured out this one.

Anybody has an idea why the uninitialized variable warning is not triggered?

I had the same issue and this was the first link on Google. I found there’s an option in my build - and I see it in your gcc command - that suppresses all warnings. -w

-w CCFLAGS Suppress all warnings, including those which GNU CPP issues by default.

https://docs.platformio.org/en/latest/projectconf/section_env_build.html#id2

I removed this from my platformio.ini and now get warnings