Missing file-errors in some cases of #define

Hi
i have a code here, and i wanted to start to put in some output to the serial terminal to test it a bit.
To be able to enable or disable the terminal output i created a line this way:

#define SER 1

//#define NEOLED_INIT 1
//#define NEOLED 1
#define OLED_INIT 1
#define OLED 1
#define USBMIDI 1
//#define STDMIDI 1
#include <EEPROM.h>
#ifdef OLED_INIT
  #include <SPI.h>
  #include <Wire.h>
  #include <Adafruit_GFX.h>
  #include <Adafruit_SSD1306.h>

  #define OLED_RESET -1
  #define SCREEN_WIDTH 128 // OLED display width, in pixels
  #define SCREEN_HEIGHT 64 // OLED display height, in pixels

  Adafruit_SSD1306 OLEDMatrix(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#endif

This line brings the following error:

/home/tutorius/Arduino/USB-Midi1/midi-nano/midi_micro_new_ino/midi_micro_new_ino.ino:9:10: fatal error: EEPROM.h: No such file or directory
   #include <SPI.h>
          ^~~~~~~~~ 
compilation terminated.

I can change this code by removing the line 2.

/home/tutorius/Arduino/USB-Midi1/midi-nano/midi_micro_new_ino/midi_micro_new_ino.ino:10:12: fatal error: SPI.h: No such file or directory
   #include <Wire.h>
            ^~~~~~~

Two lines free:

/home/tutorius/Arduino/USB-Midi1/midi-nano/midi_micro_new_ino/midi_micro_new_ino.ino:10:10: fatal error: EEPROM.h: No such file or directory
   #include <Wire.h>
          ^~~~~~~~~~
compilation terminated.


Three lines free:

/home/tutorius/Arduino/USB-Midi1/midi-nano/midi_micro_new_ino/midi_micro_new_ino.ino:11:10: fatal error: EEPROM.h: No such file or directory
   #include <Adafruit_GFX.h>
          ^~~~~~~~~~
compilation terminated.

The version with five inserted blank lines can be compiled...

I have read about comparable error-messages in this forum from 2017, long ago. Any solutions?

Used IDE:

Version: 2.2.1
Date: 2023-08-31T14:16:33.536Z
CLI Version: 0.34.0

Copyright © 2023 Arduino SA

Using Linux and the Appimage.

Thanks a lot.

SER might be a reserved word. What happens if you change it to SERDBG?

Changed it to SERD, same behaviour.

When its a reserved word, it should not work in every case. I can't see a way that a reserved word works well with much blank lines after it.

I have added some more #defines afer SER (SERD), and the free lines are still needed, after the last #define.

Which board are you compiling for?
If you copy the code from your initial post and paste it into a new sketch, do you still get the same errors? I have no problem compiling it here on the same version of the IDE on linux.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.