compile errors w/ ShipDesign

Questions, problems and discussion about compiling FreeOrion.

Moderator: Oberlus

Post Reply
Message
Author
User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

compile errors w/ ShipDesign

#1 Post by Dilvish »

Hi, so today I'm getting compile errors apparently related to ShipDesign.cpp and/or Condition.cpp. I'm not sure what's up though since it looks like neither of those was touched for over a week. It's been a few days or so since I last compiled, but I thought it was within the past week, while sorting out the issue with Version.cpp.

Later today I'll try to step through revisions to see where the trouble starts, but just in case anything comes to mind for someone, here's the errors I'm getting (and I already tried clearing out all cmake cache files):

Code: Select all

FO@amber:~/Downloads/FreeOrion$ make -j2
[  1%] Building CXX object CMakeFiles/core.dir/universe/Condition.cpp.o
[ 16%] Built target parse
[ 17%] Built target ltdl
[ 23%] Built target log4cpp
[ 24%] Building CXX object CMakeFiles/core.dir/universe/PopCenter.cpp.o
/home/FO/Downloads/FreeOrion/universe/Condition.cpp:3215:69: error: incomplete type ‘ShipDesign’ used in nested name specifier
/home/FO/Downloads/FreeOrion/universe/Condition.cpp: In function ‘int {anonymous}::NumberOnQueue(const ProductionQueue&, BuildType, int, const string&, int)’:
/home/FO/Downloads/FreeOrion/universe/Condition.cpp:3229:34: error: incomplete type ‘ShipDesign’ used in nested name specifier
/home/FO/Downloads/FreeOrion/universe/Condition.cpp:3235:80: error: ‘GetShipDesign’ was not declared in this scope
/home/FO/Downloads/FreeOrion/universe/Condition.cpp:3236:50: error: invalid use of incomplete type ‘const class ShipDesign’
In file included from /home/FO/Downloads/FreeOrion/universe/Fleet.h:5:0,
                 from /home/FO/Downloads/FreeOrion/universe/Condition.cpp:7:
/home/FO/Downloads/FreeOrion/universe/Universe.h:30:7: error: forward declaration of ‘const class ShipDesign’
/home/FO/Downloads/FreeOrion/universe/Condition.cpp: In member function ‘virtual void Condition::Enqueued::Eval(const ScriptingContext&, Condition::ObjectSet&, Condition::ObjectSet&, Condition::SearchDomain) const’:
/home/FO/Downloads/FreeOrion/universe/Condition.cpp:3304:77: error: incomplete type ‘ShipDesign’ used in nested name specifier
/home/FO/Downloads/FreeOrion/universe/Condition.cpp: In member function ‘virtual bool Condition::Enqueued::Match(const ScriptingContext&) const’:
/home/FO/Downloads/FreeOrion/universe/Condition.cpp:3428:73: error: incomplete type ‘ShipDesign’ used in nested name specifier
/home/FO/Downloads/FreeOrion/universe/Condition.cpp: In member function ‘virtual bool Condition::DesignHasHull::Match(const ScriptingContext&) const’:
/home/FO/Downloads/FreeOrion/universe/Condition.cpp:3800:27: error: invalid use of incomplete type ‘const class ShipDesign’
In file included from /home/FO/Downloads/FreeOrion/universe/Fleet.h:5:0,
                 from /home/FO/Downloads/FreeOrion/universe/Condition.cpp:7:
/home/FO/Downloads/FreeOrion/universe/Universe.h:30:7: error: forward declaration of ‘const class ShipDesign’
/home/FO/Downloads/FreeOrion/universe/Condition.cpp: In member function ‘bool {anonymous}::DesignHasPartSimpleMatch::operator()(const UniverseObject*) const’:
/home/FO/Downloads/FreeOrion/universe/Condition.cpp:3850:59: error: invalid use of incomplete type ‘const class ShipDesign’
In file included from /home/FO/Downloads/FreeOrion/universe/Fleet.h:5:0,
                 from /home/FO/Downloads/FreeOrion/universe/Condition.cpp:7:
/home/FO/Downloads/FreeOrion/universe/Universe.h:30:7: error: forward declaration of ‘const class ShipDesign’
/home/FO/Downloads/FreeOrion/universe/Condition.cpp: In member function ‘bool {anonymous}::DesignHasPartClassSimpleMatch::operator()(const UniverseObject*) const’:
/home/FO/Downloads/FreeOrion/universe/Condition.cpp:3975:59: error: invalid use of incomplete type ‘const class ShipDesign’
In file included from /home/FO/Downloads/FreeOrion/universe/Fleet.h:5:0,
                 from /home/FO/Downloads/FreeOrion/universe/Condition.cpp:7:
/home/FO/Downloads/FreeOrion/universe/Universe.h:30:7: error: forward declaration of ‘const class ShipDesign’
/home/FO/Downloads/FreeOrion/universe/Condition.cpp:3978:21: error: expected primary-expression before ‘const’
/home/FO/Downloads/FreeOrion/universe/Condition.cpp:3978:21: error: expected ‘)’ before ‘const’
/home/FO/Downloads/FreeOrion/universe/Condition.cpp:3979:25: error: ‘part_type’ was not declared in this scope
/home/FO/Downloads/FreeOrion/universe/Condition.cpp: In member function ‘virtual bool Condition::PredefinedShipDesign::Match(const ScriptingContext&) const’:
/home/FO/Downloads/FreeOrion/universe/Condition.cpp:4100:25: error: invalid use of incomplete type ‘const class ShipDesign’
In file included from /home/FO/Downloads/FreeOrion/universe/Fleet.h:5:0,
                 from /home/FO/Downloads/FreeOrion/universe/Condition.cpp:7:
/home/FO/Downloads/FreeOrion/universe/Universe.h:30:7: error: forward declaration of ‘const class ShipDesign’
/home/FO/Downloads/FreeOrion/universe/Condition.cpp:4104:39: error: invalid use of incomplete type ‘const class ShipDesign’
In file included from /home/FO/Downloads/FreeOrion/universe/Fleet.h:5:0,
                 from /home/FO/Downloads/FreeOrion/universe/Condition.cpp:7:
/home/FO/Downloads/FreeOrion/universe/Universe.h:30:7: error: forward declaration of ‘const class ShipDesign’
/home/FO/Downloads/FreeOrion/universe/Condition.cpp: In member function ‘bool {anonymous}::NumberedShipDesignSimpleMatch::operator()(const UniverseObject*) const’:
/home/FO/Downloads/FreeOrion/universe/Condition.cpp:4135:32: error: incomplete type ‘ShipDesign’ used in nested name specifier
/home/FO/Downloads/FreeOrion/universe/Condition.cpp: In member function ‘virtual bool Condition::PredefinedShipDesign::Match(const ScriptingContext&) const’:
/home/FO/Downloads/FreeOrion/universe/Condition.cpp:4105:1: warning: control reaches end of non-void function [-Wreturn-type]
make[2]: *** [CMakeFiles/core.dir/universe/Condition.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 27%] Built target pagedgeometry
make[1]: *** [CMakeFiles/core.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 52%] Built target GiGi
make: *** [all] Error 2
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: compile errors w/ ShipDesign

#2 Post by adrian_broher »

Revision 6087 removes the MultiplayerCommon.h include from the ValueRef.h header. Just add a ShipDesign.h include to Condition.cpp.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

User avatar
Dilvish
AI Lead and Programmer Emeritus
Posts: 4768
Joined: Sat Sep 22, 2012 6:25 pm

Re: compile errors w/ ShipDesign

#3 Post by Dilvish »

adrian_broher wrote:Revision 6087 removes the MultiplayerCommon.h include from the ValueRef.h header. Just add a ShipDesign.h include to Condition.cpp.
Ah, great -- that plus in ValueRef.h a <set> (which had also been provided via MultiplayerCommon.h) fixed things up for me. I went ahead and committed those two additions.

Thanks!
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0

User avatar
em3
Vacuum Dragon
Posts: 630
Joined: Sun Sep 25, 2011 2:51 pm

Re: compile errors w/ ShipDesign

#4 Post by em3 »

I don't want to sound offensive, but I always thought that relying on header files to include other header files you need is a bad programming practice... Is there a reason to group the headers into one common header?
https://github.com/mmoderau
[...] for Man has earned his right to hold this planet against all comers, by virtue of occasionally producing someone totally batshit insane. - Randall Munroe, title text to xkcd #556

User avatar
Bigjoe5
Designer and Programmer
Posts: 2058
Joined: Tue Aug 14, 2007 6:33 pm
Location: Orion

Re: compile errors w/ ShipDesign

#5 Post by Bigjoe5 »

em3 wrote:I don't want to sound offensive, but I always thought that relying on header files to include other header files you need is a bad programming practice... Is there a reason to group the headers into one common header?
It's (probably) less a question of intentionally grouping all the headers together into one common header, but rather one of someone needing to use a class that was already included in a previously included header, and not bothering to add the header to the file they were working on directly, because it already worked.

There is something to be said for including a file directly everywhere it's needed (i.e. we avoid issues like this), but there's not really any good way that I know of to do so, without checking your includes every time you use a particular datatype, and I'm certainly not aware of any quick way to apply such a policy to a large, existing project (though perhaps adrian_broher has something up his sleeve - he seems to know a lot of project-refactoring tricks).
Warning: Antarans in dimensional portal are closer than they appear.

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: compile errors w/ ShipDesign

#6 Post by adrian_broher »

Bigjoe5 wrote:There is something to be said for including a file directly everywhere it's needed (i.e. we avoid issues like this), but there's not really any good way that I know of to do so, without checking your includes every time you use a particular datatype, and I'm certainly not aware of any quick way to apply such a policy to a large, existing project (though perhaps adrian_broher has something up his sleeve - he seems to know a lot of project-refactoring tricks).
Not really. You can use serveral tools like iwyu or deheader to solve this automatically, but those are usually compiler specific (CLANG in this case).

You can do the same manually by creating a dependency graph from the includes (it's a bit of bash and graphviz magic) after that you just look up the include highest in the hierarchy and remove it. After that you recompile and add the missing includes in the cpp files, and add forward declarations and includes as needed to the header files. You repeat this until the unnecessary includes are gone. It's a bit tedious but with ccache not that time consuming as you would expect.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

User avatar
em3
Vacuum Dragon
Posts: 630
Joined: Sun Sep 25, 2011 2:51 pm

Re: compile errors w/ ShipDesign

#7 Post by em3 »

Bigjoe5 wrote:
em3 wrote:I don't want to sound offensive, but I always thought that relying on header files to include other header files you need is a bad programming practice... Is there a reason to group the headers into one common header?
It's (probably) less a question of intentionally grouping all the headers together into one common header, but rather one of someone needing to use a class that was already included in a previously included header, and not bothering to add the header to the file they were working on directly, because it already worked.
Yeah, that IS the best practice, I think.
https://github.com/mmoderau
[...] for Man has earned his right to hold this planet against all comers, by virtue of occasionally producing someone totally batshit insane. - Randall Munroe, title text to xkcd #556

Post Reply