[GH-ISSUE #1511] Unused variable breaks builds when using "All" compiler warnings #1288

Closed
opened 2026-02-28 01:29:26 +03:00 by kerem · 0 comments
Owner

Originally created by @philj404 on GitHub (Oct 14, 2022).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1511

(there is no "development" branch at the moment)

Basic Infos

I prefer to write my code with "All" compiler warnings, as I find this saves me time in the long run.

Unfortunately, some libraries are not clean enough to build with all warnings turned on.

In this case, WiFiManager looks like it is almost clean enough to do so, except for one line.

Hardware

WiFimanager Branch/Release: Master / release tag: 2.0.13-beta

Esp32:

Hardware: ESP32-wrover dev board

Core Version: (?)

Description

  • Use Arduino IDE 2.0.0 (I don't know if this is necessary)
  • Arduino File...Preferences...Compiler Warnings = "All"
  • Compile the examples/Basic/Basic.ino example

You get the following error message:

C:\Users\philk\OneDrive\Documents\Arduino\libraries\WiFiManager\WiFiManager.cpp: In member function 'boolean WiFiManager::autoConnect(const char*, const char*)':
C:\Users\philk\OneDrive\Documents\Arduino\libraries\WiFiManager\WiFiManager.cpp:282:8: error: unused variable 'wifiIsSaved' [-Werror=unused-variable]
   bool wifiIsSaved = getWiFiIsSaved();
        ^~~~~~~~~~~
cc1plus.exe: some warnings being treated as errors

exit status 1

Compilation error: exit status 1

Settings in IDE

Arduino IDE 2.0.0
Arduino File...Preferences...Compiler Warnings = "All"

Module: ESP32 2.0.4; Wrover Module

Additional libraries: N/A

The workaround seems straightforward and safe: add an "unused" attribute to flag the unused variable as "OK to ignore":

//bool wifiIsSaved = getWiFiIsSaved();                                             
bool wifiIsSaved __attribute__((unused)) = getWiFiIsSaved();

This is not flagged if warnings are set to "Default"

If it would help, I could submit a pull request for you with the change.

Originally created by @philj404 on GitHub (Oct 14, 2022). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1511 (there is no "development" branch at the moment) ### Basic Infos I prefer to write my code with "All" compiler warnings, as I find this saves me time in the long run. Unfortunately, some libraries are not clean enough to build with all warnings turned on. In this case, WiFiManager looks like it is _almost_ clean enough to do so, except for one line. #### Hardware WiFimanager Branch/Release: Master / release tag: 2.0.13-beta Esp32: Hardware: ESP32-wrover dev board Core Version: (?) ### Description - Use Arduino IDE 2.0.0 (I don't know if this is necessary) - Arduino File...Preferences...Compiler Warnings = "All" - Compile the **examples/Basic/Basic.ino** example You get the following error message: ``` C:\Users\philk\OneDrive\Documents\Arduino\libraries\WiFiManager\WiFiManager.cpp: In member function 'boolean WiFiManager::autoConnect(const char*, const char*)': C:\Users\philk\OneDrive\Documents\Arduino\libraries\WiFiManager\WiFiManager.cpp:282:8: error: unused variable 'wifiIsSaved' [-Werror=unused-variable] bool wifiIsSaved = getWiFiIsSaved(); ^~~~~~~~~~~ cc1plus.exe: some warnings being treated as errors exit status 1 Compilation error: exit status 1 ``` ### Settings in IDE Arduino IDE 2.0.0 Arduino File...Preferences...Compiler Warnings = "All" Module: ESP32 2.0.4; Wrover Module Additional libraries: N/A The workaround seems straightforward and safe: add an "unused" attribute to flag the unused variable as "OK to ignore": ``` //bool wifiIsSaved = getWiFiIsSaved(); bool wifiIsSaved __attribute__((unused)) = getWiFiIsSaved(); ``` This is not flagged if warnings are set to "Default" If it would help, I could submit a pull request for you with the change.
kerem closed this issue 2026-02-28 01:29:26 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#1288
No description provided.