<solved> invalid initialization of non-const reference

Questions, problems and discussion about compiling FreeOrion.

Moderator: Oberlus

Post Reply
Message
Author
Nexus
Space Floater
Posts: 48
Joined: Fri Aug 14, 2015 8:29 pm

<solved> invalid initialization of non-const reference

#1 Post by Nexus »

Latest version (551a79a729) fails to compile for me, on Linux Mint 17.2, 64 bit

I get this error:

Code: Select all

/home/nexus/Games/freeorion/UI/SystemIcon.cpp: In constructor ‘SystemIcon::SystemIcon(GG::X, GG::Y, GG::X, int)’:
/home/nexus/Games/freeorion/UI/SystemIcon.cpp:375:148: error: invalid initialization of non-const reference of type ‘boost::shared_ptr<GG::Texture>&’ from an rvalue of type ‘boost::shared_ptr<GG::Texture>’
     boost::shared_ptr<GG::Texture>& texture = ClientUI::GetTexture(ClientUI::ArtDir() / "misc" / "system_selection" / "system_selection2.png", true);
                                                                                                                                                    ^
/home/nexus/Games/freeorion/UI/SystemIcon.cpp:385:163: error: invalid initialization of non-const reference of type ‘boost::shared_ptr<GG::Texture>&’ from an rvalue of type ‘boost::shared_ptr<GG::Texture>’
     boost::shared_ptr<GG::Texture>& tiny_texture = ClientUI::GetTexture(ClientUI::ArtDir() / "misc" / "system_selection_tiny" / "system_selection_tiny2.png", true);
                                                                                                                                                                   ^
make[2]: *** [client/human/CMakeFiles/freeorion.dir/__/__/UI/SystemIcon.cpp.o] Error 1
make[1]: *** [client/human/CMakeFiles/freeorion.dir/all] Error 2
make: *** [all] Error 2
Any idea what's wrong?
Last edited by Nexus on Mon Sep 07, 2015 6:47 pm, edited 1 time in total.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: invalid initialization of non-const reference

#2 Post by Geoff the Medio »

Differences between compilers.

Try putting "const " before "boost::shared_ptr<GG::Texture>&" on the lines with errors.

Nexus
Space Floater
Posts: 48
Joined: Fri Aug 14, 2015 8:29 pm

Re: invalid initialization of non-const reference

#3 Post by Nexus »

That seems to have fixed that error, but now I am getting a bunch of errors like

Code: Select all

SystemIcon.cpp:379:104: error: no matching function for call to ‘RotatingGraphic::RotatingGraphic(const boost::shared_ptr<GG::Texture>&, boost::enable_if_c<true, GG::Flags<GG::GraphicStyle> >::type)’
     m_selection_indicator = new RotatingGraphic(texture, GG::GRAPHIC_FITGRAPHIC | GG::GRAPHIC_PROPSCALE);
I don't understand the code (or C++) well enough to feel confident tackling these myself.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: invalid initialization of non-const reference

#4 Post by Geoff the Medio »

Try the latest master revision (after this).

Nexus
Space Floater
Posts: 48
Joined: Fri Aug 14, 2015 8:29 pm

Re: invalid initialization of non-const reference

#5 Post by Nexus »

That's fixed the problem. Thanks!

User avatar
MatGB
Creative Contributor
Posts: 3310
Joined: Fri Jun 28, 2013 11:45 pm

Re: <solved> invalid initialization of non-const reference

#6 Post by MatGB »

I got the same errors this afternoon but had to run out before investigating, the game did run fine with the correct version string in the head tho, which I thought a bit weird. Fixed now, compiled with no errors.
Mat Bowles

Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Post Reply