Linux Compile Error in Condition.cpp SVN 4580-82

Questions, problems and discussion about compiling FreeOrion.

Moderators: Oberlus, Oberlus

Post Reply
Message
Author
metallurge
Space Floater
Posts: 20
Joined: Tue Mar 08, 2011 9:55 pm

Linux Compile Error in Condition.cpp SVN 4580-82

#1 Post by metallurge » Fri Jan 13, 2012 8:02 pm

Looks like gcc 4.6.1 doesn't like something in the recent changes to Condition.cpp:

Code: Select all

-----snip------
[  3%] Building CXX object CMakeFiles/core_static.dir/universe/Condition.cpp.o
/home/eric/Downloads/freeorion.dev/FreeOrion/universe/Condition.cpp: In function ‘std::vector<const Condition::ConditionBase*> {anonymous}::FlattenAndNestedConditions(const std::vector<const Condition::ConditionBase*>&)’:
/home/eric/Downloads/freeorion.dev/FreeOrion/universe/Condition.cpp:60:17: error: expected primary-expression before ‘const’
/home/eric/Downloads/freeorion.dev/FreeOrion/universe/Condition.cpp:60:17: error: expected ‘)’ before ‘const’
/home/eric/Downloads/freeorion.dev/FreeOrion/universe/Condition.cpp:62:51: error: expected identifier before ‘->’ token
make[2]: *** [CMakeFiles/core_static.dir/universe/Condition.cpp.o] Error 1
make[1]: *** [CMakeFiles/core_static.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

Code: Select all

eric-CQ50-LM12 ~ # gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.1-9ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
Let me know if you need more info about my build environment.



As a side note, it looks like things are really improving quickly with FreeOrion here in the last few months. Kudos!

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

Re: Linux Compile Error in Condition.cpp SVN 4580-82

#2 Post by Geoff the Medio » Fri Jan 13, 2012 11:59 pm

Can you try throwing "template " (w/o quotes) in a few places on those lines? Maybe before "vector" (after "std::")... I'm guessing there's something ambiguous to the code parser, but it's not exactly matching the situations for similar error messages I found by googling...

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

Re: Linux Compile Error in Condition.cpp SVN 4580-82

#3 Post by Geoff the Medio » Sat Jan 14, 2012 1:54 am

I'm informed that "and" is a C++ keyword. Try replacing the instances of "and" with "and_condition" and let me know if it compiles?

metallurge
Space Floater
Posts: 20
Joined: Tue Mar 08, 2011 9:55 pm

Re: Linux Compile Error in Condition.cpp SVN 4580-82

#4 Post by metallurge » Sat Jan 14, 2012 4:25 am

Geoff the Medio wrote:I'm informed that "and" is a C++ keyword. Try replacing the instances of "and" with "and_condition" and let me know if it compiles?
Ding!

The following compiles without complaint, anyway:

Code: Select all

Index: Condition.cpp
===================================================================
--- Condition.cpp	(revision 4582)
+++ Condition.cpp	(working copy)
@@ -57,9 +57,9 @@
         for (std::vector<const Condition::ConditionBase*>::const_iterator it = input_conditions.begin();
              it != input_conditions.end(); ++it)
         {
-            if (const Condition::And* and = dynamic_cast<const Condition::And*>(*it)) {
+            if (const Condition::And* and_condition = dynamic_cast<const Condition::And*>(*it)) {
                 std::vector<const Condition::ConditionBase*> flattened_operands =
-                    FlattenAndNestedConditions(and->Operands());
+                    FlattenAndNestedConditions(and_condition->Operands());
                 std::copy(flattened_operands.begin(), flattened_operands.end(), std::back_inserter(retval));
             } else {
                 retval.push_back(*it);
Relative to my procedural-programming (C) background, C++ syntax really makes my head hurt. I've been meaning to use FO as my care-enough-to-delve-into-C++ project for a while now. Perhaps I can meaningfully contribute at some point. I oughta have caught this one myself.

Post Reply