You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@lucene.apache.org by Owen McCabe <om...@gmail.com> on 2005/07/06 05:50:21 UTC

compile error with gcc 4

Hi,
I ran into a little trouble compiling lucene4c with a recent version
of gcc and I thought I'd document it here in case anyone else ran into
it. More specifically:

$ g++ --version
g++ (GCC) 4.0.1 20050517 (prerelease) (Debian 4.0.0-7ubuntu6~5.04ubp1)

gave me error messages like:

./include/org/apache/lucene/document/Field.h:24: error: global
qualification of class name is  invalid before : token

This seems to stem from gcc refusing to compile code like this:

namespace extra {
  class test;
}

class ::extra::test {
};

int main() {
}

That compiles just fine under both gcc 3.3 and the latest version of
comeau. The only reference I could find to this on google was:

http://gcc.gnu.org/ml/gcc-regression/2004-04/msg00018.html

So I'm not sure if it's back to compiling in a newer version or not yet.

Anyway, it's easy to work around it by replacing all the "class
::org"s in the header files with "class org" in lines like this:

class ::org::apache::lucene::document::Field : public ::java::lang::Object

So I'm not sure if the extra ::s are actually needed or not.

-owen

Re: compile error with gcc 4

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
Owen McCabe wrote:
> Hi,
> I ran into a little trouble compiling lucene4c with a recent version
> of gcc and I thought I'd document it here in case anyone else ran into
> it. More specifically:
> 
> $ g++ --version
> g++ (GCC) 4.0.1 20050517 (prerelease) (Debian 4.0.0-7ubuntu6~5.04ubp1)
> 
> gave me error messages like:
> 
> ./include/org/apache/lucene/document/Field.h:24: error: global
> qualification of class name is  invalid before : token
> 
> This seems to stem from gcc refusing to compile code like this:
> 
> namespace extra {
>   class test;
> }
> 
> class ::extra::test {
> };
> 
> int main() {
> }
> 
> That compiles just fine under both gcc 3.3 and the latest version of
> comeau. The only reference I could find to this on google was:
> 
> http://gcc.gnu.org/ml/gcc-regression/2004-04/msg00018.html
> 
> So I'm not sure if it's back to compiling in a newer version or not yet.
> 
> Anyway, it's easy to work around it by replacing all the "class
> ::org"s in the header files with "class org" in lines like this:
> 
> class ::org::apache::lucene::document::Field : public ::java::lang::Object
> 
> So I'm not sure if the extra ::s are actually needed or not.

Weird.  It's kind of odd that g++ is failing to compile headers 
generated by gcj...  I'd say that unless it's actually failing for a 
released version of gcc there isn't a whole lot of point in us doing 
anything about it though.

-garrett