microsoft / vscode-arduino

Visual Studio Code extension for Arduino
Other
1.17k stars 226 forks source link

Switched to arduino-cli, no more warnings #1638

Open coffeemachine-ftq opened 1 year ago

coffeemachine-ftq commented 1 year ago

Since I switched to arduino-cli, I no longer get warnings for my code. It looks like we need a way to pass to following arguments to arduino-cli

--warnings all

See arduino-cli compile documentation

Since compiler warnings are an essential developer tool, they should be enabled by default. When I use arduino-cli from the command line with --warnings all I get the output I want.

I tried other alternatives using buildPreferences in arduino.json, none of them was successful:

jmailloux commented 1 year ago

I see this issue as well. I have this in arduino.json: "buildPreferences": [ ["build.extra_flags", "-Wall -Wextra"] ]

I found that actually -Wall -Wextra do get added in the compiler command. However, they don't do anything because -w (which inhibits all warnings) is inserted earlier on in the compiler invocation. So as coffeemachine-ftq says, looks like we need a way to pass --warnings all to arduino-cli.

jmailloux commented 1 year ago

This is the only thing keeping me from using arduino-cli in VSCode.

rajivk-slx commented 1 year ago

Is there a known workaround for this?

TheAlgorythm commented 1 year ago

@rajiv-obh i have created a workaround which works with the current megaavr core and presumably most others.

sed -i 's|compiler.warning_flags=-w|compiler.warning_flags=-Wall -Wextra -pedantic|g' /root/.arduino15/packages/arduino/hardware/**/**/platform.txt
sed -i 's|=-w |=|g' /root/.arduino15/packages/arduino/hardware/**/**/platform.txt

The warning level can be adjusted by changing -Wall -Wextra -pedantic in the first command to the supposed one like -W.