C++ Static String Causes Segmentation Fault
Theodore Papadopoulo
Theodore.Papadopoulo@sophia.inria.fr
Thu Jul 23 13:00:00 GMT 2009
Ben Atkinson wrote:
> Thanks for the response, Ian. With an eye toward correcting the problem
> in my source code, does C++ make any guarantees about global
> constructors in the same source?
>
A more robust scheme is to create a function (or static member function)
that returns the
static string, and using this function to get the string...
class XXX {
...
static std:string& mystring() { static std::string foo = "whatever";
return foo; }
...
};
More information about the Libstdc++
mailing list