Re: g++ Locale ?? correction

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

 



On 2017-05-03 01:32 -0400, Papa wrote:
> Thanks all for the help.
> 
> Here is an update to my code
> <snip>
> void setGlobalLocale(const std::string& str) noexcept {
>       std::string tmp;
>       tmp = std::setlocale(LC_ALL, str.c_str());
> }
> </snip>

`noexcept` just stop the program while there is an exception
thrown in the function.  It does not help.

> This also ends with this message:
> =======================================================
> Output file is bin\Debug\Locale.exe with size 3.78 MB
> Process terminated with status 0 (0 minute(s), 4 second(s))
> 0 error(s), 0 warning(s) (0 minute(s), 4 second(s))
> 
> 
> -------------- Run: Debug in Locale (compiler: GNU GCC 
> Compiler)---------------
> 
> Checking for existence: [DRIVE]\Locale.exe
> Executing: "[DRIVE]\CodeBlocks\Locale\bin\Debug\Locale.exe"  (in 
> C:\Users\Papa\Documents\CodeBlocks\Locale\bin\Debug)
> Process terminated with status 255 (0 minute(s), 4 second(s))
> 
> =================================================

On my Win7 VM (with GCC-4.7.1-tdm) the result is status 3. 
Which version of GCC are you using?  (I'm not sure why it's 255
on your machine).

This issue happens because libstdc++ doesn't support std::locale
on Windows.  It just throw exception when you try to create a
non-"C" locale.

Liu Hao (CCed him) once said his (maybe modified) libstdc++
also support locale name "" (empty string).  Maybe he can help
you.

There are some discussions about enhance generic locale code
with C89/C99 APIs.  But there are many issues must be solved.
So libstdc++ still supports only "C" locale today. See
<http://gcc.gnu.org/ml/libstdc++/2003-02/msg00345.html>.

If we want to implement full locale support on Windows, and
w/o touching Windows internal undocumented APIs and legal
issues about Windows, we have to parse locale string
everywhere, and deal multi-thread things carefully.

If possible, I suggest you to use C89/C99 API directly.  It's
more portable, but need more string parsing (locale strings
are everywhere in C89/C99 locale.h).
-- 
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