This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: linkage prob...
- From: "Andrea 'fwyzard' Bocci" <fwyzard at inwind dot it>
- To: "Itay 'z9u2K' Duvdevani" <z9u2k at bezeqint dot net>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Fri, 03 Jan 2003 18:01:25 +0100
- Subject: Re: linkage prob...
At 18.46 03/01/2003 +0200, Itay 'z9u2K' Duvdevani wrote:
Hey,
I need an "extern static const" decleration, but it is forbidden...
at the moment, my app won't link...
No, you don't need it to be static...
The following works for me (RedHat 8.0, GCC 3.2) :
decl.h:
namespace a
{
namespace b
{
class x;
// ...
}
}
*********
x.h:
#include "decl.h"
class a::b::x
{
public:
// ...
static const int q1;
};
**********
x .cpp:
#include "x.h"
const int a::b::x::q1 = 4;
// ...
********
main.cpp:
#include "decl.h"
#include "x.h"
#include <iostream>
using namespace a;
using namespace a::b;
int main()
{
std::cout << x::q1; // will not link... g++ says:
// main.cpp:8: undefined reference to `a::b::x::q1[in-charge](int const&)'
}
Couldn't compile without these correctiosn.
fwyzard