Hi,
I wonder, that a freshly installed Arduino IDE 2.2 fails to compile the standard example Esp32RotaryEncoderBasics.ino with the board TTGO T1.
I get error message
d:\Activities\3_Maker\libraries\Ai_Esp32_Rotary_Encoder\src\AiEsp32RotaryEncoder.cpp: In member function 'ButtonState AiEsp32RotaryEncoder::readButtonState()':
d:\Activities\3_Maker\libraries\Ai_Esp32_Rotary_Encoder\src\AiEsp32RotaryEncoder.cpp:279:14: error: unused variable '_buttonState' [-Werror=unused-variable]
ButtonState _buttonState = buttonState;
^~~~~~~~~~~~
cc1plus.exe: some warnings being treated as errors
exit status 1
Compilation error: exit status 1
Is the library broken for ESP32 hardware?
Compiling it for ESP8266 gets warnings but finishes gracefully.
The ESP32 boards platform is unique in that the compilation result is affected by the setting of Arduino IDE's "Compiler warnings" preference.
Traditionally this preference has only influenced how many warnings we see in the compilation output, but the Arduino boards platform framework allows each platform developer to decide exactly what effect they want each of the levels of this preference to have. The ESP32 developers decided to add the -Werror=all flag to the compilation command when you set the "Compiler warnings" preference to the "More" or "All" levels. This flag causes compilation to fail when the sketch code produces a compilation warning.
There are two possible approaches to resolve the error:
Fix Warnings
The ESP32 developers configured their boards platform this way to encourage writing code that does not produce warnings. Compiler warnings often indicate a problem with the code so it is a good idea to pay attention to them and fix them.
Even in cases where the warning does not indicate a problem in the code, an accumulation of such warnings makes it difficult to spot the significant warnings in the output so it is a good idea to adjust the code to suppress these warnings as well.
If you would like advice on how to best address specific warnings produced by your code, the helpers here can assist with that.
You may find that some warnings come from code you didn't write (e.g., a library used by your sketch). If you decide to fix those warnings, it's a good idea to submit the fix to the source of the code (e.g., a pull request to the GitHub repository where it is hosted). This benefits you by avoiding having to fix the warnings all over again whenever you update to a new release of the code. This will also benefit all the other users of the code.
Reduce Warning Level
You should pay attention to warnings and fix them in your own code whenever possible. Unfortunately you may find that some warnings come from code you didn't write (e.g., a library used by your sketch). These warnings can also be fixed, but you may decide that it isn't worth the effort to fix problems in other people's code. If so, you can reduce the level of the "Compiler warnings" preference to avoid the warnings causing a compilation error:
Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
The "Preferences" dialog will open.
Select "Default" from the "Compiler warnings" menu in the "Preferences" dialog.