Arduino Forum

Using Arduino => Programming Questions => Topic started by: howroyd on Nov 17, 2011, 04:15 pm

Title: 'LOW' was not declared in this scope
Post by: howroyd on Nov 17, 2011, 04:15 pm
I am splitting my code up into tab (so seperate .cpp and .h files) to keep things organised, then using #includes to bring it all together.

I'm aware of the need to "#include <WProgram.h>" because I'm using "analogRead()", however I am getting the following compiler error on a different object.  I'm assuming it's a similar problem that I need to include a random header because it's not in a .pde file, and LOW is a standard declaration.

Does anyone know the solution?

Quote
In file included from pointers.cpp:4:
/REALTIME.h: In constructor 'CTime::CTime()':
REALTIME.h:7: error: 'LOW' was not declared in this scope


pointers.pde is the main file
realtime.h and .cpp are an included object that has the following line in it:
Code: [Select]
ledState=LOW;

To all those helping, many thanks.  I have Googled this but found nothing, nor anything in the forums.
Title: Re: 'LOW' was not declared in this scope
Post by: PaulS on Nov 17, 2011, 04:25 pm
Quote
I'm assuming it's a similar problem that I need to include a random header because it's not in a .pde file, and LOW is a standard declaration.

I suppose you could just try adding a random header file. When you choose the right random header file (wiring.h), the results would be better.
Title: Re: 'LOW' was not declared in this scope
Post by: howroyd on Nov 17, 2011, 04:38 pm
Good idea, just tried every header file in /hardware/ardiono/cores/ardiuino/ which is where WProgram.h is.  No luck.

EDIT:
Found the problem, the variable I was setting to LOW was a global variable.  For some reason it didnt like this, so I have made it a local variable & now it compiles.

So, dodgy error message; LOW is valid, what you're assigning it to is not (in my case anyway!0

cheers
Title: Re: 'LOW' was not declared in this scope
Post by: nickgammon on Nov 17, 2011, 08:37 pm

Found the problem, the variable I was setting to LOW was a global variable.  For some reason it didnt like this, so I have made it a local variable & now it compiles.


???

Never heard of this before, that you can't assign LOW to global variables.
Title: Re: 'LOW' was not declared in this scope
Post by: pYro_65 on Nov 17, 2011, 09:12 pm


Found the problem, the variable I was setting to LOW was a global variable.  For some reason it didnt like this, so I have made it a local variable & now it compiles.

???



Too true, scope of objects plays no part in this. Adding the header include after the variable declaration will produce this.