How is the correct way of declaring a static string variable? If I compile the following program, clang will give me some warnings.
#include<string>
class foo {
public:
static std::string bar;
};
std::string foo::bar;
int main()
{
foo::bar = "test";
}
Output:
test.cpp:8:18: warning: declaration requires a global constructor [-Wglobal-constructors]
std::string foo::bar;
^~~
test.cpp:8:18: warning: declaration requires an exit-time destructor [-Wexit-time-destructors]
test.cpp:8:18: warning: declaration requires a global destructor [-Wglobal-constructors]
I call clang with "clang++ test.cpp -o test -Weverything" and I don't get any warnings if bar is e.g. an int.