This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: using xlocale to implement std::locale class


I understand the thread safety issues with locale, now.
However, aren't they handled with xlocale's newlocale, duplocale, freelocale, uselocale API?


I'm trying myself to compile on darwin by copying the contents of config/locale/gnu to config/locale/darwin directory and trying to fix which cannot be compiled. (I know how configure script works, and regenerated the script to surely handle my new code.)

Now I have a problem:
__c_locale is not compatible with locale_t which is defined in xlocale.
The def. of __c_locale: typedef int* __c_locale; (in c++locale.h)
The def. of locale_t : typedef struct _xlocale * locale_t; (in /usr/include/xlocale.h on darwin)


For example, the call for wctype_l won't compile because 2nd argument is called with __c_locale typed variable ctype::_M_c_locale_ctype.
(Since the difference is just the type of pointers, reinterpret_cast will conceal the problem. But just I don't want such a workaround.)


I see at least two possible solutions.
1. make ctype::_M_clocale_ctype a type of locale_t
2. make __c_locale type the same as locale_t
Which is the better?, or any other solutions?
(I don't know the history of how locale_t or xlocale is constructed, so I can't imagine redefining them breaks other things to what extent.)


--
   Takeshi Kobayakawa

(11/05/04 17:38), Jonathan Wakely wrote:
On 4 May 2011 07:07, Marc Glisse wrote:
On Wed, 4 May 2011, Takeshi Kobayakawa wrote:

Are there any effort to handle std::locale class with xlocale(extended
locale support)? (here, xlocale.h has nothing to do with XLib' Xlocale.h)

There has been for a while, in libstdc++-v3/config/locale/gnu/.


I am a navite linux programmers, but when I tried to port my code to
darwin(MacOSX), I found one can not create locale object other than "C"
locale. The libstdc++ seems to deal with darwin, so I would like to see
std::locale object working better on darwin.

I didn't know things were that bad...

Locales need a lot of work everywhere except GNU/Linux. There are thread safety issues, 64-bit issues, and failures to handle some wchar_t character classes on some platforms.

I plan to attack the problems, but it's not a priority for me as I
only need to use GNU/Linux these days.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]