Endif without if ошибка

Новую версию сбивают с толку маркеры порядка байт в начале файлов, из-за этого она не видит макрос #ifndef в самом начале файла, и как результат ругается на закрывающий #endif без пары.

Arduino: 1.8.15 (Windows 10), Плата:"Arduino Nano, ATmega328P"


In file included from C:UserssimikDownloadsChristmasLights-masterfirmwarenotamesh4_gyver_v1.11main.ino:162:0:
rainbow_beat.h:14:2: error: #endif without #if
 #endif
  ^~~~~
In file included from C:UserssimikDownloadsChristmasLights-masterfirmwarenotamesh4_gyver_v1.11main.ino:166:0:
blendwave.h:29:2: error: #endif without #if
 #endif
  ^~~~~
In file included from C:UserssimikDownloadsChristmasLights-masterfirmwarenotamesh4_gyver_v1.11main.ino:167:0:
fire.h:57:2: error: #endif without #if
 #endif
  ^~~~~
In file included from C:UserssimikDownloadsChristmasLights-masterfirmwarenotamesh4_gyver_v1.11main.ino:168:0:
candles.h:27:2: error: #endif without #if
 #endif
  ^~~~~
In file included from C:UserssimikDownloadsChristmasLights-masterfirmwarenotamesh4_gyver_v1.11main.ino:169:0:
colorwave.h:78:2: error: #endif without #if
 #endif
  ^~~~~
exit status 1
#endif without #if

I have an extrange Problem…
I have written this short code:

////////////// BOARD SETTINGS \\\\\\\
#define BAUD_RATE 9600

// Board type selection
// Uncomment the wanted
//#define WAND 0
//#define GUN 0
#define RIFLE 0


////////////// WAND SETTINGS \\\\\\\
#ifdef WAND
//#define USE_CHARGER 0

#endif

////////////// GUN SETTINGS \\\\\\\
#if GUN
//#define USE_CHARGER 0

#endif

////////////// RIFLE SETTINGS \\\\\\\
#ifdef RIFLE
  #define USE_CHARGER 0

#endif

It’s in a file called Settings.h, that I use in the main code:

#include "Settings.h"

void setup(){
  Serial.begin(BAUD_RATE);
  #ifdef WAND
    Serial.println("Initializing Wand...");
  #endif
  #ifdef GUN
    Serial.println("Initializing Gun...");
  #endif
  #ifdef RIFLE
    Serial.println("Initializing Rifle...");
  #endif
}

void loop(){
  #ifdef WAND

  #endif
  #ifdef GUN

  #endif
  #ifdef RIFLE

  #endif
}

But for an extrange reason, it gives me this error: error: #endif without #if
Full error is:

In file included from D:MEGAWinsoftProjectsHardwareMWandsArduino_5Arduino_5.ino:1:0:

Settings.h:15: error: #endif without #if

 #endif

  ^

Settings.h:21: error: #endif without #if

 #endif

  ^

Settings.h:27: error: #endif without #if

 #endif

  ^

exit status 1
#endif without #if

Any idea in where am I wrong?

And taking advantage that I’m asking, is necessary the 0 after #define RIFLE 0, next to each definition?

  • Forum
  • General C++ Programming
  • #endif without #if

#endif without #if

I know it sounds stupid but I really need your help with this annoying error. I caught the error «#endif without #if» while I already had #ifndef before #endif. I am checking the code again now but still have no idea what the problem is. Please help me. Thank you very much!

Post the code you’re having a problem with. We’re not psychic. Although I am spying through your window, I’m a bit shortsighted.

If you search for ‘#’ in the source code you might find the problem.

If you already have a #endif then look i between the #if and the #endif for an extra #endif

yeah i found it :D there’s an endif between my if and endif :D thanks a lot :D

Last edited on

Topic archived. No new replies allowed.

RepRap forum

I was following a «How To» on adding Marlin and the BL Touch sensor. When I finished the instructions and verified the file I came up with the following error.

exit status 1
#endif without #if

#endif //__CONFIGURATION_H

Would someone be willing to look at my Congifuration.h file and see where I went wrong? I read a couple of articals, but those apparently weren’t my issue. sad smiley

Attachments:

open | download —
Configuration.h
(55.1 KB)

you have

//#if ENABLED(RGB_LED)
#define RGB_LED_R_PIN 34
#define RGB_LED_G_PIN 43
#define RGB_LED_B_PIN 35
#endif

change first line to
#if ENABLED(RGB_LED)

that didn’t make any difference sad smiley

Looks like a superfluous line to me… I suggest you try commenting out the offending #endif and see if it will then compile

// #endif //_CONFIGURATION_H

failing that..try

#endif CONFIGURATION_H

Edited 1 time(s). Last edit at 03/17/2017 01:51PM by dart16.

У меня есть дополнительная проблема…
Я написал этот короткий код:

////////////// BOARD SETTINGS \\\\\\\
#define BAUD_RATE 9600

// Выбор типа платы
// Раскомментировать желаемое
//#define WAND 0
//#define GUN 0
#define RIFLE 0


////////////// WAND SETTINGS \\\\\\\
#ifdef WAND
//#define USE_CHARGER 0

#endif

////////////// GUN SETTINGS \\\\\\\
#if GUN
//#define USE_CHARGER 0

#endif

////////////// RIFLE SETTINGS \\\\\\\
#ifdef RIFLE
  #define USE_CHARGER 0

#endif

Он находится в файле под названием Settings.h, который я использую в основном коде:

#include "Settings.h"

void setup(){
  Serial.begin(BAUD_RATE);
  #ifdef WAND
    Serial.println("Initializing Wand...");
  #endif
  #ifdef GUN
    Serial.println("Initializing Gun...");
  #endif
  #ifdef RIFLE
    Serial.println("Initializing Rifle...");
  #endif
}

void loop(){
  #ifdef WAND

  #endif
  #ifdef GUN

  #endif
  #ifdef RIFLE

  #endif
}

Но по посторонней причине это выдает мне следующую ошибку: ошибка: #endif без #if
Полная ошибка заключается в следующем:

In file included from D:MEGAWinsoftProjectsHardwareMWandsArduino_5Arduino_5.ino:1:0:

Settings.h:15: error: #endif without #if

 #endif

  ^

Settings.h:21: error: #endif without #if

 #endif

  ^

Settings.h:27: error: #endif without #if

 #endif

  ^

exit status 1
#endif without #if

Есть какие-нибудь идеи в том, где я ошибаюсь?

И, пользуясь тем, что я спрашиваю, необходимо ли 0 после #define RIFLE 0рядом с каждым определением?

Понравилась статья? Поделить с друзьями:
  • End randomseed ошибка virtualbox
  • End oil ошибка кариер
  • End of statement expected python ошибка
  • End hot ошибка на рефрижераторе кариер
  • Encryption unsuccessful как исправить ошибку