I know this has been asked multiple times but could not find a post relating to this specific problem:
# config.h
String g_ssid = "";
# webserver.cpp
#include "config.h"
bool saveConfig(String *ssid, String *pass)
{
// Open config file for writing.
File configFile = SPIFFS.open("/cl_conf.txt", "w");
if (!configFile)
{
Serial.println("Failed to open cl_conf.txt for writing");
return false;
}
// Save SSID and PSK.
configFile.println(*ssid);
configFile.println(*pass);
configFile.close(); // <-- error in this line???
return true;
} // saveConfig
Compile error:
webserver.cpp.o: In function `saveConfig(String*, String*)':
C:\Users\AppData\Local\Temp\build9148105163386366718.tmp/webserver.cpp:114: multiple definition of `g_pass'
Declaring as inline is not possible as the compiler complains:
'g_ssid' declared as an 'inline' variable
Obviously extern
ing the variable from config.h doesn't make much sense as far as the purpose of config.h is concerned. How can this be solved?