Hello,
This thread follow my previous one on the gcc mailing list. Basically I
-still- have a problem in my code. I define in a header file:
static const std::string foo = "bar";
Which not only seems to be a bad practice but also creates a bug on
MacOSX panther (gcc 3.3).
Could someone suggest me a better approach than this one. Knowing that
I need to have a const reference access to the string.
I tried the approach :
// header.H
extern const std::string foo;
//implementation.C
const std::string foo = "bar";
but this doesn't seems to work with VS6/7: error LNK2019: unresolved
external symbol ...
---------
Gabriel Dos Reis (from the gcc ML) proposed the following approach:
// header.H
const std::string& foo();
// implementation.C
const std::string& foo() {
static const std::string instance = "foo";
return instance;
}
Comments/suggestions very welcome.
Thanks,
Mathieu