E
Eric Lilja
So I tried to compile code that my boss wrote with a newer compiler
than I was previously using (FYI, the code compiles fine on g++ 3.4.4
but not on 4.1.1). I condensed it into this simple testprogram:
#include <string>
class Foo
{
private:
static const std::string LETTERS;
};
using namespace std;
namespace
{
const string Foo::LETTERS("abc");
}
int
main()
{
Foo f;
(void)f;
}
I must admit I'm not entirely sure what he want the anonymous (correct
term?) namespace for, but the more recent compiler sure doesn't like
it:
$ g++ --version
g++ (GCC) 4.1.1
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
$ g++ -Wall -Wextra -std=c++98 -pedantic foo.cpp -o runme.exe
foo.cpp:13: error: definition of 'Foo::LETTERS' is not in namespace
enclosing 'Foo'
I need you gurus on this one.
/ E
than I was previously using (FYI, the code compiles fine on g++ 3.4.4
but not on 4.1.1). I condensed it into this simple testprogram:
#include <string>
class Foo
{
private:
static const std::string LETTERS;
};
using namespace std;
namespace
{
const string Foo::LETTERS("abc");
}
int
main()
{
Foo f;
(void)f;
}
I must admit I'm not entirely sure what he want the anonymous (correct
term?) namespace for, but the more recent compiler sure doesn't like
it:
$ g++ --version
g++ (GCC) 4.1.1
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
$ g++ -Wall -Wextra -std=c++98 -pedantic foo.cpp -o runme.exe
foo.cpp:13: error: definition of 'Foo::LETTERS' is not in namespace
enclosing 'Foo'
I need you gurus on this one.
/ E