ESP32 Arduino-IDE 1.8.19 compiler warnings ALL treat warning not as error

Hi Everybody,

today I re-compiled a sketch for ESP32 that uses the onewire.h-library
Usually I have set the compiler-warnings to ALL.
With this code that uses the onewire-library the compiler aborts with this

F:\myData\Arduino\libraries\OneWire\OneWire.cpp: In member function 'uint8_t OneWire::reset()':

F:\myData\Arduino\libraries\OneWire\OneWire.cpp:167:24: error: unused variable 'reg' [-Werror=unused-variable]

  volatile IO_REG_TYPE *reg IO_REG_BASE_ATTR = baseReg;

                        ^~~

F:\myData\Arduino\libraries\OneWire\OneWire.cpp: In member function 'void OneWire::write_bit(uint8_t)':

F:\myData\Arduino\libraries\OneWire\OneWire.cpp:201:24: error: unused variable 'reg' [-Werror=unused-variable]

  volatile IO_REG_TYPE *reg IO_REG_BASE_ATTR = baseReg;

                        ^~~

F:\myData\Arduino\libraries\OneWire\OneWire.cpp: In member function 'uint8_t OneWire::read_bit()':

F:\myData\Arduino\libraries\OneWire\OneWire.cpp:229:24: error: unused variable 'reg' [-Werror=unused-variable]

  volatile IO_REG_TYPE *reg IO_REG_BASE_ATTR = baseReg;

                        ^~~

cc1plus.exe: some warnings being treated as errors

I remember in the back of my head that I read somewhere a little bit that

treating warnings as errors that cause the compile to abort compiliation
can be changed in some corefile.
Is this correct? If yes in which file to I have to change what that a warning is just a warning in the log but the compiler gies on with compiling and uploading?

best regards Stefan

Why anyone would want warnings to be treated as errors is beyond me and I have to put things right after every update of the ESP32 board files

The instructions are in this topic, specifically for Windows but I assume that a similar process can be followed for other Operating Systems

It would be really nice if the library owners would look at the warnings and fix their code before releasing the library.

I agree, but in reality it is not going to happen

But in any case, I don't understand why the warnings are being treated as errors

Because someone asked for it, in this case

-Werror=unused-variable

I would set warnings to errors maybe if I truly did not want an executable to be produced on accident.

Warnings are easy to miss, or ignore. Making them show-stoppers has a logic to it.

I don't know who or what dragged in the -Wunused-variable flag.

I do it know if -Wall does that. I do know that -Wall does not turn on all warnings. :expressionless:

a7

I know what causes warnings to be regarded as errors (and how to stop it) but what I don't understand is why someone decided to do it

It is particularly irksome when there are unused variables in a library

@UKHeliBob

thank you very much for posting the link.

best regards Stefan

Well, all-of-a-sudden I started to get unnecessary warnings I never in many years had before.
With Arduino 1.18.3, every time I initialize a parameter to be read from a serial port like byte x=0; x=Serial.read(), with Arduino 1.18.3, the warning tells me: "warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized].
If, as suggested, I omit the "byte x = 0", I obviously get, as expected, the ERROR message:
"error: 'x' was not declared in this scope".
With Arduino 2.3.2, the same code, I do not receive the warning (but, obviously the expected error message).
I really hate seeing red warnings or error messages in my projects.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.