[GH-ISSUE #1813] Strange errors #1529

Open
opened 2026-02-28 01:30:25 +03:00 by kerem · 1 comment
Owner

Originally created by @sds5111 on GitHub (Apr 9, 2025).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1813

Can someone please tell me why the following code will not work? It is an issue with c++, not WiFiManager itself, but I can't find an answer anywhere.

1#include <Arduino.h>
2#include <FS.h> //this needs to be first, or it all crashes and burns...
3#include <WiFiManager.h>
4void setup()
5{
6WiFiManager wifimanager;
7WiFiManager wm;
8WiFiManager.resetSettings(); //reset settings
9if (!WiFiManager.autoConnect("AutoConnectAP", "password"))
10}
Line 8 which has a red squiglly line under the "," after WiFiManager. If I place the cursor over it,, the error is "expected an identifier"
Line 9 which has a red squiglly line under WiFiManager. If I place the cursor over it,, the error is "type name is not allowed",

This code used to work, now it doesn't. I don't know what I'm doing wrong, but would greatly appreciate some help.

Originally created by @sds5111 on GitHub (Apr 9, 2025). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1813 Can someone please tell me why the following code will not work? It is an issue with c++, not WiFiManager itself, but I can't find an answer anywhere. 1#include <Arduino.h> 2#include <FS.h> //this needs to be first, or it all crashes and burns... 3#include <WiFiManager.h> 4void setup() 5{ 6WiFiManager wifimanager; 7WiFiManager wm; 8WiFiManager.resetSettings(); //reset settings 9if (!WiFiManager.autoConnect("AutoConnectAP", "password")) 10} Line 8 which has a red squiglly line under the "," after WiFiManager. If I place the cursor over it,, the error is "expected an identifier" Line 9 which has a red squiglly line under WiFiManager. If I place the cursor over it,, the error is "type name is not allowed", This code used to work, now it doesn't. I don't know what I'm doing wrong, but would greatly appreciate some help.
Author
Owner

@timr49 commented on GitHub (Apr 17, 2025):

The code has at least five problems:

  1. It defines two instances of the class WiFiManager in lines 6 & 7. This is almost certainly not what you want.
  2. The instances of WiFiManager are defined inside setup() which means they will cease to exist when setup() returns.
  3. It uses a type name in line 8 where a variable name is expected (presumably it should be either wm or wifimanager).
  4. Same as above in line 9.
  5. There is no statement after the "if" in line 9, not even a semi-colon.

As you said, this is all about C++ and not about WiFiManager, so you might be better off finding an appropriate forum.

<!-- gh-comment-id:2811581754 --> @timr49 commented on GitHub (Apr 17, 2025): The code has at least _five_ problems: 1. It defines _two_ instances of the class WiFiManager in lines 6 & 7. This is almost certainly _not_ what you want. 2. The instances of WiFiManager are defined inside setup() which means they will cease to exist when setup() returns. 3. It uses a type name in line 8 where a variable name is expected (presumably it should be either `wm` or `wifimanager`). 4. Same as above in line 9. 5. There is no statement after the "if" in line 9, not even a semi-colon. As you said, this is all about C++ and not about WiFiManager, so you might be better off finding an appropriate forum.
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#1529
No description provided.