I have the following code:
template<size_t N>
size_t sendProgmem(WiFiClient client, const String prog_char(&str)[N])
// size_t sendProgmem(WiFiClient client, const prog_char (&str)[N])
{
return sendProgmem(client, str, N);
}
size_t sendProgmem(WiFiClient client, const String prog_char progmem[], size_t size) {
size_t maxSize=2920; // this seems to be the max that write() will ever actually send
size_t sent=0;
while(sent < size) {
size_t sendSize = (maxSize < (size - sent)) ? maxSize : (size - sent);
sent += client.write(progmem+sent, sendSize); // write() may send less than you asked it to
}
return sent;
}
The original line (3rd line of code, now commented) produced an error:
"ISO C++ forbids declaration with no type"
so I added String (see 2nd line of code).
Now I get,
error: expected ',' or '...' before '(' token
2 | size_t sendProgmem(WiFiClient client, const String prog_char(&str)[N])
The original code is some 5+ years old. I'm not a C++ programmer so I don't even know where to start.
Any help as to where I can start looking or what is wrong with this syntax?
Also, what is the basic explanation of '(&str)[N]'?