I can't use any locale except "C" under c++
snnn
snnn119 at gmail.com
Tue Apr 11 14:31:21 UTC 2006
I think that's because FreeBSD is building gcc with
--enable-clocale=generic and the generic code for _S_create_c_locale is
as such:
void
locale::facet::_S_create_c_locale(__c_locale& __cloc, const char* __s,
__c_locale)
{
// Currently, the generic model only supports the "C" locale.
// See http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html
__cloc = NULL;
if (strcmp(__s, "C"))
__throw_runtime_error(__N("locale::facet::_S_create_c_locale "
"name not valid"));
}
So even if the simplest (e.g. the following one) code will always catch
a failure.
try{
std::locale::global(std::locale(""));
}
catch(std::runtime_error ex){
//fail...
std::locale::global(std::locale("C"));
}
Indeed,std::locale("") will return the default locale setting of native
environment(similar as setlocale("") ),but now it may always throw an
error of "name not valid".It's badly.
what should I do?
install another gcc from ports?
More information about the freebsd-questions
mailing list