Skip to main content
clarify
Source Link
JRobert
  • 15.4k
  • 3
  • 25
  • 53

The C & C++ compilers don't look for language syntax inside quoted strings (except for character-escapes such as '\n'). That is the point of quoting the string.

This program just compiled Ok for me:

const char webpage[] PROGMEM = R"=====( 
<html>
  <head>
    <script src=\"https://cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.6/svg.min.js\"></script>
  </head>
  <body>
  </body>
</html>
)=====";

void setup() {
}

void loop() {
}

'//' within a quotedthe string did not cause aany problem. With yourYour example, I did get an error message that the variable 'webpage' had to be const to put it in Flash memory so I added the 'const' keyword, but that is the only change I made.

If you do that, and your compiler is still complaining, there is some other issue than the '//'.

This program just compiled Ok for me:

const char webpage[] PROGMEM = R"=====( 
<html>
  <head>
    <script src=\"https://cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.6/svg.min.js\"></script>
  </head>
  <body>
  </body>
</html>
)=====";

void setup() {
}

void loop() {
}

'//' within a quoted string did not cause a problem. With your example, I did get an error message that the variable 'webpage' had to be const to put it in Flash memory so I added the 'const' keyword, but that is the only change I made.

If you do that, and your compiler is still complaining, there is some other issue than the '//'.

The C & C++ compilers don't look for language syntax inside quoted strings (except for character-escapes such as '\n'). That is the point of quoting the string.

This program just compiled Ok for me:

const char webpage[] PROGMEM = R"=====( 
<html>
  <head>
    <script src=\"https://cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.6/svg.min.js\"></script>
  </head>
  <body>
  </body>
</html>
)=====";

void setup() {
}

void loop() {
}

'//' within the string did not cause any problem. Your example did get an error message that the variable 'webpage' had to be const to put it in Flash memory so I added the 'const' keyword, but that is the only change I made.

If you do that, and your compiler is still complaining, there is some other issue than the '//'.

Source Link
JRobert
  • 15.4k
  • 3
  • 25
  • 53

This program just compiled Ok for me:

const char webpage[] PROGMEM = R"=====( 
<html>
  <head>
    <script src=\"https://cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.6/svg.min.js\"></script>
  </head>
  <body>
  </body>
</html>
)=====";

void setup() {
}

void loop() {
}

'//' within a quoted string did not cause a problem. With your example, I did get an error message that the variable 'webpage' had to be const to put it in Flash memory so I added the 'const' keyword, but that is the only change I made.

If you do that, and your compiler is still complaining, there is some other issue than the '//'.