Going back to some code for the ESP32 that I had previously used, it will now not compile
Simplifying the code down to
void setup()
{
byte foo;
}
void loop()
{
}
produces this error
Arduino: 1.8.13 (Windows 10), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, Core 1, Core 1, None, Disabled"
C:\Users\Bob2\AppData\Local\Temp\arduino_modified_sketch_992452\sketch_oct06b.ino: In function 'void setup()':
sketch_oct06b:3:8: error: unused variable 'foo' [-Werror=unused-variable]
byte foo;
^~~
cc1plus.exe: some warnings being treated as errors
exit status 1
unused variable 'foo' [-Werror=unused-variable]
This is using IDE 1.8.13 with the ESP 32 Dev board as its target and the ESP board files version 2.0.5 which is the latest offered by the IDE and which has been installed for some time. Reverting to version 2.0.4 of the ESP32 boards file produces the same error but the code compiles with version 2.0.3 and not even a warning is produced. All compiler warnings are turned on
Unsurprisingly the code compiles, albeit with a warning, when the target is an AVR such as the Nano
I can find no reference to this problem in the forum or online, but can anyone else confirm that the problem exists for them, or not, of course ?
can you set the preferences so that warnings aren't treated as errors?
there's a reason treating warnings as errors, which i believe is very good practice, is optional. there's a need to be able to compile older working code that has acceptable flaws.
What I don't understand is that this objectionable behavior happens in IDE v1.8.15 but not v1.8.19. However the 'platform.txt' file is specific to the ESP32 board package and I have the same package v2.0.6 installed in both of the above IDE versions.
I tried commenting the declaration. It turns out the variable was indeed used later on and I got a true error. This is using ide 2.1.0 on code that worked on a 8266 and trying on a C3.