{Solved} PROGMEM variable and conditional compilation

Greetings,

I am trying to put my HTML code for an ESP8266/Arduino webpage in PROGMEM like this

const char INDEX_HTML[] PROGMEM = R"=====(
<!DOCTYPE HTML lang="en-US">
<html>
  <head>
</head>
<body>
  <h1>Captive Portal Main Page</h1> 


</body>
</html>
)=====";

on top of that i am trying to use condional compilation like this

#define TESTBUTTON  
#ifdef TESTBUTTON
   // some code here
#endif

i am trying to use the conditional compilation in the webpage like this

const char INDEX_HTML[] PROGMEM = R"=====(
<!DOCTYPE HTML lang="en-US">
<html>
  <head>
</head>
<body>
  <h1>Captive Portal Main Page</h1> 


#ifdef TESTBUTTON
  <h2>test</h2>
#endif
</body>
</html>
)=====";

i show the webpage like this

String s = INDEX_HTML;
server.send(200, "text/html", s);

however, when compiling with TESTBUTTON not defined (commented out) the

test

still appears.

I am sure it is my (lack of) understanding of PROGMEM that is causing the issue.

If someone knows how to do this, let me know, please

thanks for your time,

Rob

Preprocessing directives do not work inside string literals.
However, you can split the literal into parts; multiple adjacent string literals are combined into one.
For example

"foo"
   "bar"

becomes

"foobar"
const char INDEX_HTML[] PROGMEM = R"=====(
<!DOCTYPE HTML lang="en-US">
<html>
  <head>
</head>
<body>
  <h1>Captive Portal Main Page</h1> 


)====="

#ifdef TESTBUTTON
  "<h2>test</h2>\n"
#endif

  R"=====(
</body>
</html>
)=====";

look at the page source code in the browser. is there #ifdef TESTBUTTON ?

@oqibidipo, You are the man!!!!! that worked for me. Thanks a million.

@Juraj, yes, it did show.