Endif without if ошибка

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

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


In file included from C:\Users\simik\Downloads\ChristmasLights-master\firmware\notamesh4_gyver_v1.1\1main.ino:162:0:
rainbow_beat.h:14:2: error: #endif without #if
 #endif
  ^~~~~
In file included from C:\Users\simik\Downloads\ChristmasLights-master\firmware\notamesh4_gyver_v1.1\1main.ino:166:0:
blendwave.h:29:2: error: #endif without #if
 #endif
  ^~~~~
In file included from C:\Users\simik\Downloads\ChristmasLights-master\firmware\notamesh4_gyver_v1.1\1main.ino:167:0:
fire.h:57:2: error: #endif without #if
 #endif
  ^~~~~
In file included from C:\Users\simik\Downloads\ChristmasLights-master\firmware\notamesh4_gyver_v1.1\1main.ino:168:0:
candles.h:27:2: error: #endif without #if
 #endif
  ^~~~~
In file included from C:\Users\simik\Downloads\ChristmasLights-master\firmware\notamesh4_gyver_v1.1\1main.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:\MEGA\Winsoft\Projects\Hardware\MWands\Arduino_5\Arduino_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.

Previous topic — Next topic

Feeling like a newb
Here is the code..
IT PRODUCES AN ERROR — ENDIF without IF
THE ‘IF’ STATEMENT IS CLEARLY PRESENT SO IS THIS A BUG?
// ——————————— //
// Project: omgbug
// Start: Saturday, September 28, 2013
// IDE Version: 10.202
// SETCURRENTDIR(«Media») // go to media files

DIM mynumber%[6]
//create an array of numbers for sort
mynumber%[1] = 5
mynumber%[2] = 3
mynumber%[3] = 1
mynumber%[4] = 2
mynumber%[5] = 6
mynumber%[6] = 4

//bubblesort the array
FOR a% = 1 TO 5
   FOR b% = a%+1 TO 6
       IF a%<>B% AND mynumber[a%] > mynumber[b%] THEN   
           memory%=mynumber%[b%]
          mynumber%[b%]=mynumber%[a%]
          mynumber%[a%]=memory%       
      ENDIF   
   NEXT
NEXT

FOR i%= 1 TO 6
PRINT i% + » » + mynumber%[i%], 100 + (i%*20),100
NEXT


Welcome.

It looks fine to me,
I think you don´t need that «THEN» on the IF line, only when you single line stuff.
For example:

If erico=coolguy then world=better

In your case, you have multiple results so:

If erico=coolguy
    world=better
    life=good
    ckrum=welcome
endif

I think that might be the answer.
You should also use the # up there the post window when posting code, makes it easier to test.
Like this:

if codetag=1
forum=clean
check=1
endif

Welcome again! :)


You are Genius!
Thank you very much.
I just found and bought the GLBasic today.
Thanks to you my program runs correctly.
It is a simulation of the lottery drawing to help the user generate a unique set of numbers.
It simulates an actual drawing by mixing virtual lottery balls rather than generating random numbers.
Not like that is going to help me win the lottery but the concept provided some enthusiasm on my part to fight the syntax.

Thank you again.


hehe nice idea! I did a random number generator a couple years ago on the purpose that my my machine+GLB would make it an easy win…well, I didn´t win, probably cause my machine was angry. ;/

You will see GLB is a fine tool, check the online manual or press F1 in program and you pretty much get all you need to start up good.
This forum is also gold stuffed with examples and solutions beyond belief. Some questions can be answered with a simple search.

Enjoy!


You might want to look at the SWAP command for your bubble-sorting function.

Welcome BTW. :)


Hi crum Welcome to the Comunity…

About your program don’t care I did the same when I bought GLbasic but I continue poor, I don’t win the Lottey  :D :D

About your code the error it’s like says Erico you forget put the Endif, my counsil it’s aleways read what says  the compiler, the bottom part of your screen, I never read when I start to do code and it’s a great error, you will learn a lot spend a bit of time reading what happends in your code…

Ah don’t believe what’s says erico about a good boy… he’s a «cabroncete» JAJAJ  =D =D =D :good:

Regards, and any question here you can find very very clever people and perfect answers.
Willkomen   :booze:


Quote from: ckrum on 2013-Sep-29

It simulates an actual drawing by mixing virtual lottery balls rather than generating random numbers.
Not like that is going to help me win the lottery but the concept provided some enthusiasm on my part to fight the syntax.

I´m pretty sure you will manage to resolve it.

Then, you could also take it a bit further and add visuals and sound.
That code could be a great playground to test and check out multimedia commands in GLB, specially if you already have the code (logic part) working perfectly beneath it.

Let us know the results! Say, I´m even willing to try out your soft´s numbers on the lottery here. :good:

Quote from: mentalthink on 2013-Sep-29

Ah don’t believe what’s says erico about a good boy… he’s a «cabroncete» JAJAJ  =D =D =D :good:

What!!! Hehe, lots of clever people with a great sense of humor around here! :P ;)


Don’t forget that GLBasic has the very efficient Quicksort sorting routine in the name of SORTARRAY available…


SORTARRAY is indeed good, unless you need to swap more than one array at a time. In this case it would be OK, but for a high score table it’s not so good (where you are changing scores, names and possibly level attained etc.)


I was trying to explain the simplest way of doing the array sorting, rather than going into the nitty-gritty ;)

OP was using a bubble-sorting method and SWAP would reduce the amount of code without altering it considerably. It fitted in well with what he had — more so than SORTARRAY or datastructures.


thanks… I think I am gonna enjoy GLB esp when I get the freakin thing to build the apk files.. :rant:


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.

Понравилась статья? Поделить с друзьями:
  • Endever индукционная плита ошибка e5 исправить
  • Ems 11182 ошибка скания
  • Endever индукционная плита ошибка e3 решение
  • Enderal код ошибки 54
  • Ems 11176 скания ошибка