Bringing variable declaration from text document into program code

I am have trouble declaring a char array in flash memory from a text document. The array contains HTML code.
When I try to bring the file into my code with:

#include “Blinker.h”

I get a syntax error and I can not figure out why…

Here is the “Blinker.h” text document:

const char* Blinker_page PROGMEM = R"=====(

Sensor Value:0

Blinker Lights

)====="; -----------------------------

Here is my error message:

In file included from C:\Users\nicol\Documents\Arduino\Tasks\Tasks.ino:11:0:

sketch\Blinker.h:1:12: error: uninitialized const ‘Blinker_page’ [-fpermissive]

const char Blinker_page; PROGMEM = R"=====(

^

sketch\Blinker.h:1:25: error: expected unqualified-id before ‘[’ token

const char Blinker_page; PROGMEM = R"=====(

^

Thank you for your consideration!

Why are you trying to mislead people here?

Your error message clearly shows that you have a ; after Blinker_page and no * before Blinker_page:
const char Blinker_page**;** PROGMEM

Your alleged “code” has no ; after Blinker_page, but has a * before Blinker_page:
const char__*__ Blinker_page PROGMEM

The code you posted here is NOT the code you actually tried to compile. Please, do not make up false stories about the code here. This will only prevent people from helping you. And you will get caught quickly.


Both variants are incorrect though.

The proper syntax is

const char Blinker_page[] PROGMEM = R"=====(
<!DOCTYPE html>
...whatever...
</html>
)=====";

and it compiles without any problems.

Why the R ahead of the first double quote?

Don't the embedded double quotes have to be handled specially?

I admit that I have not yet tried to compile this. I am currently away from my Arduino IDE.

vaj4088:
Why the R ahead of the first double quote?

It is a special syntax that creates a so called raw string literal. Available since C++11, which is incidentally what Arduino IDE uses for C++ code.

String literal - cppreference.com (see variant 6)

The whole R"=====( part is actually an extended “opening quote”. The literal contents begins after the (.

vaj4088:
Don’t the embedded double quotes have to be handled specially?

No they don’t. That’s the whole idea of this language feature. Everything inside the (...) is taken literally, as written, including newlines. By using raw laterals you can copy-paste “War and Peace” into your source code as a string literal without having to worry about any special handling for the characters Leo used when he typed up his masterpiece.

Thanks, I will learn from the link. Most of my knowledge is based on an old version of C, but I can learn new tricks.