Collisions in header guards for multiple inclusions can cause these kind of things.
x.h contains:
#ifndef X
#define X (1)
/* stuff */
#endif
Yet some previous thing defined X so that subsequent header file is never processed.
To track down these kind of problems add
#error __FILE__ __LINE__
inside #if s to see where the code actually gets.
#error will stop the compiler at that point.
Remove that one and see if gets to the next one that you think it should.
Also is the error message 'undeclared' or 'undefined' these are two different things?
'undefined' would indicate a problem with the macro definition.
'undeclared indicates a problem with its usage.
Does the variable actually exist? Is it misspelled in some subtle way?