Getting this error:
C:\Users\Michael\Documents\Arduino\8266Templ\8266Templ.ino:36:17: error: expected constructor, destructor, or type conversion before '(' token
36 | setVariableValue("hostname", hostname);
| ^
I'v searched the forum and google, and the problems they describe, i just don't see in my code.
The only thing odd i am doing is i wrote this code as a standalone sketch, and now just want to use those functions in another sketch.
Have commented out the problematic pieces that the IDE just is not allowing.
IDE 2.1.1, can't upgrade on a Windows 8.1 machine.
I've even attempted the "protyping" code, but it doesn't seem to help.
Main sketch, down to where it fails anyway:
// File name 8266Templ.ino
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266mDNS.h>
#include <ESP8266WebServer.h>
#include "ESPFlash.h"
#include "StringSplitter.h"
// In separate .ino
// String substituteVariables(const String formatString);
void setVariableValue(String varName, String value);
#ifndef STASSID
#define STASSID "***"
#define STAPSK "***"
#endif
const char *ssid = STASSID;
const char *password = STAPSK;
String gethostname(bool full) {
String result = __FILE__;
if (full) {
return result;
} else {
int idx = String(__FILE__).indexOf(".ino");
if (idx > 0) {
result = result.substring(0, idx);
}
return result;
}
}
String hostname = gethostname(false);
setVariableValue("hostname", hostname);
And the actual function, from the other sketch:
void setVariableValue(String varName, String value) {
int i = 0;
int siz = sizeof(varArr) / sizeof(varStruct);
varStruct tmpArr[] = {};
if (getVariableValue(varName) == "") {
if (siz != 0) {
tmpArr[siz + 1] = {};
for (; i < siz; i++) {
tmpArr[i] = varArr[i];
}
// i++
}
tmpArr[i] = { varName, value };
varArr[sizeof(tmpArr) / sizeof(varStruct)] = {};
for (i = 0; i < sizeof(tmpArr) / sizeof(varStruct); ++i) {
varArr[i] = tmpArr[i];
}
} else {
for (i = 0; i < sizeof(varArr) / sizeof(varStruct); ++i) {
if (varArr[i].name == varName) {
varArr[i].value = value;
break;
}
}
}
}
Any help would be greatly appreciated.