Undeclared Identifier Madness!!!

I am having trouble getting all these bizarre errors to go away - namely it is just C2065 and C2146 that I think are causing chain errors, but I have included a full list of all errors if that helps put whatever my problem is in context:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Error	1	error C2065: 'People' : undeclared identifier	floor.h	12
Error	2	error C2065: 'People' : undeclared identifier	elevator.h	34
Error	4	error C2143: syntax error : missing ';' before '<'	elevator.h	33
Error	5	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int	elevator.h	33
Error	6	error C2238: unexpected token(s) preceding ';'	elevator.h	33
Error	7	error C2143: syntax error : missing ';' before '<'	elevator.h	34
Error	8	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int	elevator.h	34
Error	9	error C2238: unexpected token(s) preceding ';'	elevator.h	34
Error	10	error C2146: syntax error : missing ';' before identifier 'buildingFloor'	building.h	14
Error	11	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int	building.h	14
Error	12	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int	building.h	14
Error	13	error C2146: syntax error : missing ';' before identifier 'buildingFloor'	building.h	14
Error	14	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int	building.h	14
Error	15	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int	building.h	14
Error	16	error C2146: syntax error : missing ';' before identifier 'buildingElevator'	building.h	15
Error	17	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int	building.h	15
Error	18	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int	building.h	15


I have tried searching endlessly to find a solution to these mysterious errors -such as Error 16 - but I have not come across anything online that details what the problem is. I simply saw threads stating the problem is that there is a missing ";" but I have looked through the code, and still do not see any red squiggly lines highlighting an area where there are errors in my code. I would like to believe my error is something that simple but I fear it is something far worse unfortunately.

Below I will provide the main classes and header files for this program, an elevator simulation where these errors are occurring.

However, it will just be the #include areas of each one because I am reaching the limit for characters to post, and I personally think the way my #include are set up in each file may be causing this problem. If a detailed post of the code is needed that is no problem to do.

building.h
1
2
3
#pragma once

#include "elevator.h" 


building.cpp
1
2
3
#include "building.h"
#include <iostream>


elevator.h
1
2
3
4
5
#pragma once

#include "floor.h"

using namespace std; //this seems to fix a few problems 


elevator.cpp
 
#include "elevator.h" 


floor.h
1
2
3
4
#pragma once

#include "people.h"
#include <vector> 


floor.cpp
 
#include "floor.h" 


people.h
1
2
3
4
#pragma once


#include "building.h" 


people.cpp
 
#include "people.h" 


As you may have noticed, each file essentially is chained to the next file including everything the other file includes - which I personally think may be causing the problem.

I mainly just want to get those designated errors above to go away before I can focus on trying to get the elevator sim to actually work the way it should.
Last edited on
You would seem to have a circular dependency between whatever is defined in people.h and floor.h, since people.h indirectly includes floor.h and floor.h directly includes people.h.
Generally it's a good idea to start with the first error and work your way down form there, solving one at a time.

The first error is obvious, the "People" class or identifier is being used in a scope which does not have access to it... without full source it will be near impossible for us to help you with that.

If you're having issues posting full source here then you could post it into PasteBin and post a link here.

I found something about that on this site here:

http://stackoverflow.com/questions/8526819/c-header-files-including-each-other-mutually

So I changed it to put all the necessary #include header files into the source file of each header file, but that gives tons of new errors saying the program cannot identify what each object is in their header files.
I don't include a header file in another header file.

Instead I use the header files to link cpp files together.

I have a main cpp file that includes all the header files of other cpp files.

Maybe that helps.
I just solved this, maybe not the best way, but at least it runs now. Instead of having separate files for each and every object, I simply threw all these objects together in a single file, since they all need to know what the other is, and that worked!

I do not know why I did not think of this sooner, as that is the format I have seen done in my programming Physics class I have been taking for the last 7 weeks! Thanks much for the replies.
Last edited on
Topic archived. No new replies allowed.