Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Apr 2006 19:44:10 +0800
From:      snnn <snnn119@gmail.com>
To:        freebsd-questions@freebsd.org
Subject:   I can't use any locale except "C" under c++
Message-ID:  <443B968A.2020209@gmail.com>

next in thread | raw e-mail | index | archive | help
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?









Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?443B968A.2020209>