Build errors
Build errors
I'm getting a ton of these, what do they mean?
chili_framework\engine\energyboost.h(10): error C2061: syntax error: identifier 'Ship' (compiling source file Main.cpp)
chili_framework\engine\energyboost.h(10): error C2061: syntax error: identifier 'Ship' (compiling source file Main.cpp)
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Build errors
Well, either energyboost.h doesn't include ship.h OR you have energyboost.h including ship.h AND ship.h includes energyboost.h
Can't include A into B and B into A, it's called a circular dependency.
Chili covers this in one of his vids.
Can't include A into B and B into A, it's called a circular dependency.
Chili covers this in one of his vids.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Build errors
Or it means you have forward declared Ship; class Ship and are trying to use it or store it as an object in energyboost.h somewhere. In order to forward declare a class, you can only
store a reference or pointer in the class that needs it
or
pass by reference or pointer to a function that uses it
For instance, if EnergyBoost wants to know about Ship but Ship.h already #includes EnergyBoost.h then you can forward declare Ship ( class Ship; ) at the top of energyboost.h above the class declaration. Then you can pass the Ship by reference to the functions. You must however, then #include sihp.h in energyboost.cpp.
store a reference or pointer in the class that needs it
or
pass by reference or pointer to a function that uses it
For instance, if EnergyBoost wants to know about Ship but Ship.h already #includes EnergyBoost.h then you can forward declare Ship ( class Ship; ) at the top of energyboost.h above the class declaration. Then you can pass the Ship by reference to the functions. You must however, then #include sihp.h in energyboost.cpp.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: Build errors
I'm not seeing any of that. Energyboost includes ship but ship doesn't include energyboost
I'm getting tons of similar ones for energyboost and also for energyboostmanager and game.cpp
it also says
error C2660: 'MineManager::Update': function does not take 2 arguments
: error C2660: 'EnergyBoostManager::Update': function does not take 2 arguments
error C2660: 'MineManager::Draw': function does not take 2 arguments
error C2660: 'EnergyBoostManager::Draw': function does not take 2 arguments
even tho they all take 2 arguments
and also these
.h(18): error C3646: 'eBoost': unknown override specifier (compiling source file EnergyBoost.cpp)
energyboostmanager.h(18): error C2143: syntax error: missing ',' before '[' (compiling source file EnergyBoost.cpp)
energyboostmanager.h(18): error C2143: syntax error: missing ')' before ';' (compiling source file EnergyBoost.cpp)
even tho there seem to be no syntax errors
I'm getting tons of similar ones for energyboost and also for energyboostmanager and game.cpp
it also says
error C2660: 'MineManager::Update': function does not take 2 arguments
: error C2660: 'EnergyBoostManager::Update': function does not take 2 arguments
error C2660: 'MineManager::Draw': function does not take 2 arguments
error C2660: 'EnergyBoostManager::Draw': function does not take 2 arguments
even tho they all take 2 arguments
and also these
.h(18): error C3646: 'eBoost': unknown override specifier (compiling source file EnergyBoost.cpp)
energyboostmanager.h(18): error C2143: syntax error: missing ',' before '[' (compiling source file EnergyBoost.cpp)
energyboostmanager.h(18): error C2143: syntax error: missing ')' before ';' (compiling source file EnergyBoost.cpp)
even tho there seem to be no syntax errors
Re: Build errors
okay noticed something weird now
in game.h I have ship object, minemanager object and energyboostmanager object
in the header I have included all 3 ship.h minemanager.h and energyboostmanager.h
if I delete minemanager.h and ship.h nothing happens but if I delete energyboostmanager.h I can no longer make an object from that class
in game.h I have ship object, minemanager object and energyboostmanager object
in the header I have included all 3 ship.h minemanager.h and energyboostmanager.h
if I delete minemanager.h and ship.h nothing happens but if I delete energyboostmanager.h I can no longer make an object from that class
Re: Build errors
hmmm, i just forked your repo and it builds fine. You should update your repo when asking for support, can make the process a lot smoother
Chili
Re: Build errors
Sorry. I pushed it now, it's a complete train wreck lol
Re: Build errors
Well sir, first glance I see that Mine.h includes Ship.h includes MineManager.h includes Mine.h includes Ship.h ....
You got yourself a nice circular dependency there
You got yourself a nice circular dependency there
Chili
Re: Build errors
chili wrote:Well sir, first glance I see that Mine.h includes Ship.h includes MineManager.h includes Mine.h includes Ship.h ....
You got yourself a nice circular dependency there
ouff.. I'm fucked then? I can't delete any of these
Re: Build errors
There are 2 solutions.
1) Preferred: Design your system to have a non-cyclic dependency tree. This is preferred, and it is what I am demonstrating in all of the examples I've given so far in the tutorials.
2) Forward Declaration: in the headers, usually the compiler doesn't need to know the details of a class, just that that class is a thing that exists, and the actual definition can be deferred until you get to to the .cpp file where the actual functions are defined and where the class is actually used.
Let me see if it is an easy solve.
1) Preferred: Design your system to have a non-cyclic dependency tree. This is preferred, and it is what I am demonstrating in all of the examples I've given so far in the tutorials.
2) Forward Declaration: in the headers, usually the compiler doesn't need to know the details of a class, just that that class is a thing that exists, and the actual definition can be deferred until you get to to the .cpp file where the actual functions are defined and where the class is actually used.
Let me see if it is an easy solve.
Chili