Re: g++ Locale ?? correction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2017-05-02 00:08 -0400, Papa wrote:
> COLLECT_GCC=C:\gnu\mingw-w64\mingw64\bin\g++.exe
> COLLECT_LTO_WRAPPER=C:/gnu/mingw-w64/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/6.3.0/lto-wrapper.exe
> Target: x86_64-w64-mingw32
> OS: Win 8.1
> class myClass{
>     private:
>      std::locale current_locale;
>     public:
>      void setGlobalLocale(const std::string& str) {
>          current_locale.global(std::locale(str.data())); 
> //<<Segmentation fault>>

Are you sure this is a segfault?

>      }
> };
> 
> 
> On 01-May-2017 11:57 PM, Papa wrote:
> > COLLECT_GCC=C:\gnu\mingw-w64\mingw64\bin\g++.exe
> > COLLECT_LTO_WRAPPER=C:/gnu/mingw-w64/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/6.3.0/lto-wrapper.exe 
> > 
> > Target: x86_64-w64-mingw32
> > OS: Win 8.1
> > class{
> >    private:
> >     std::locale current_locale;
> >    public:
> >     void setGlobalLocale(const std::string& str) {
> >         current_locale.global(std::locale(str)); //<< RunTimeError>>
> >     }
> > };
> > 
> > I'm writing a wrapper for std::locale, but right at start-up the first 
> > problem.
> > Why would this member function give me a Run Time Error?
> > 
> > Any help is much appreciated.
> > 

Currently libstdc++ only supports "C" locale on Windows.
See <http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html>.

If you are trying to create a std::locale which is not "C", you'll likely
get

> terminate called after throwing an instance of 'std::runtime_error'
>   what():  locale::facet::_S_create_c_locale name not valid

Windows has some strange undocumented APIs for manipulating
locales.  So it's difficult to implement std::locale for Windows.
-- 
Xi Ruoyao <ryxi@xxxxxxxxxxxxxxxxx>
School of Aerospace Science and Technology, Xidian University




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux