Invalid Error? caused by #ifndef

Currently playing with an R4 Uno Wifi but I'm getting a really strange error.

In the Web Server for Arduino examples the example "Web server" sketch can be verified and compiled without issue.

The same .h files produce an error in my sketch though and it is really not clear why - the syntax is valid but the compiler isn't playing nice and I get this error

In file included from C:\Fan_Temp_Control\Fan_Temp_Control.ino:37:0:
C:\Fan_Temp_Control\home.h:3:4: error: invalid preprocessing directive #d

the file is identical to the one in the example - it was copied and pasted -

#ifndef HOME_H
#define HOME_H

const char HOME_PAGE[] PROGMEM = R"rawliteral(
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="icon" href="data:,">
  <title>Arduino Web Server</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      text-align: center;
      margin: 50px;
      background-color: #f5f5f5;
    }
    .container {
      max-width: 600px;
      margin: 0 auto;
      background-color: white;
      padding: 30px;
      border-radius: 10px;
      box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
    h1 {
      color: #333;
      margin-bottom: 30px;
    }
    .nav-menu {
      list-style: none;
      padding: 0;
      margin: 0;
    }
    .nav-item {
      margin: 15px 0;
    }
    .nav-link {
      display: inline-block;
      padding: 15px 30px;
      text-decoration: none;
      background-color: #007bff;
      color: white;
      border-radius: 5px;
      font-size: 16px;
      min-width: 200px;
      transition: background-color 0.3s;
    }
    .nav-link:hover {
      background-color: #0056b3;
    }
    .description {
      margin: 30px 0;
      color: #666;
      font-size: 14px;
    }
  </style>
</head>
<body>
  <div class="container">
    <h1>Arduino Uno R4 WiFi Web Server</h1>
    <div class="description">
      <p>Welcome to the Arduino web server demo!</p>
      <p>Explore the features below:</p>
    </div>
    <ul class="nav-menu">
      <li class="nav-item">
        <a href="/temperature" class="nav-link">🌡️ Temperature Data</a>
      </li>
      <li class="nav-item">
        <a href="/led" class="nav-link">💡 LED Control</a>
      </li>
    </ul>
    <br><br><br><br>
    This works with Arduino Uno R4 WiFi and <a href="https://diyables.io/products/diyables-stem-v4-iot-fully-compatible-with-arduino-uno-r4-wifi" target="_blank">DIYables STEM V4 IoT</a>
  </div>
</body>
</html>
)rawliteral";

#endif

In the webserver ino this compiles with no issues - in my sketch it does not

This is the declaration in my sketch - again identical to the example - and yet my sketch flat out will not compile. I am trying to add web access to an existing sketch

#include <WiFiS3.h>
#include <UnoR4WiFi_WebServer.h>
#include "home.h"
#include "temperature.h"
#include "led.h"

Is there some compiler directive I'm missing in the IDE ? - can't find one if there is #ifndef is perfectly valid so why would the compiler accept it in one sketch but blow it out in another.

The error is more than likely in the code that you did not share. Please post all code.

Please show the error message in FULL

In file included from C:\Fan_Temp_Control\Fan_Temp_Control.ino:37:0:
C:\Fan_Temp_Control\home.h:3:4: error: invalid preprocessing directive #d
  
 
    ^
In file included from C:\Fan_Temp_Control\Fan_Temp_Control.ino:37:0:

Pointing to something that does NOT exist ...

If this line was not truncated by you while inserting to the message, it seems that you have an incomplete #d directive in the code.

It also seems that the file home.h you posted to forum is not the same that used in compilation.

Well it is the same - I don't have an incomplete #ifndef or a #define that is truncated - wouldn't have posted here if it was that obvious. The file was copied from the example there should be no reason for this error

Then I don't see why the error message indicates an incomplete directive. Forgive me, but I'm more inclined to trust the compiler...

Did you try to compile the example code WITHOUT your changes?

the example compiles fine - haven't changed it - just copied the .h files from it into my sketch - and my sketch won't compile with them

The error will be on another line. Turn on All warnings, and/or switch from #ifdef guards to #pragma once

I'll give that a shot - will come back later with a result - day jobs interfering

Line 3, column 4 — that's pointing at the d in #define. The compiler is treating #define as an invalid directive, which means it's not seeing #define as a complete token. This could mean there is a hidden character between # and define introduced during copy-paste possibly or some non-breaking space.

The file would look identical because your text editor renders these invisible characters normally, but the compiler chokes on them.

Well the error was elsewhere but not what was expected - the problem was hidden characters not visible. J-M-L you are correct - unfortunately I overwrote the faulty files without thinking.

When I copied the files instead of actually copying the file I had created new .h as text files then copied text into them - notepad complained about ANSI vs Unicode - saved as unicode.

I tried removing all reference except the declarations and still the same issue.

Located and copied the files from the example instead of copying text and now it compiles fine - the IDE doesn't expose the hidden characters whatever they were - nor did notepad++ but clearly the compiler could see something.

Once I figure out how this all works I'll be recreating H files for the web interface anyhow.

If you only use the IDE editor you will not have the problem.