Go Down

Topic: 'LOW' was not declared in this scope (Read 1 time) previous topic - next topic

howroyd

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.

PaulS

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.

howroyd

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

Nick Gammon


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.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

pYro_65



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.

Go Up