using xlocale to implement std::locale class
Takeshi Kobayakawa
tskoba@tskoba.mydns.jp
Sat May 7 03:12:00 GMT 2011
> Someone who cares about darwin needs to contribute code if they want changes ...
So, now I'm trying :-)
Now, I can get to compile std::locale using xlocale's newlocale, ...
API's on darwin. It seems working for a very simple case.
I couldn't find numeric, monetary, time, functionaities on darwin, so I
just used the code for them from config/locale/generic directory. Others
are based from config/locale/gnu directory and modified to work.
>> 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)
The situation I said above was due to my misconfiguration. There is no
inconsistent declarations. I just had to add
typdef locale_t __locale_t;
(I first configure with --enable-clocale=generic, then reconfigure with
--enable-clocale, followed by make distclean. It was the cause of
misconfiguration.)
Now, I am happy to prepare and provide a patch, if it is desired.
However, I am not sure in the following points. I think these points
should be clear before the code is provided for a wide use.
1) The scope (linker name) of xlocale API
what should be the scope of the symbols of newlocale, freelocale, ...
etc. function calls? In GNU/Linux, they are __newlocale, __freelocale,
... etc. But, I could not get them link in darwin, so I defined like
#define __newlocale newlocale
in c++locale_internal.h
(In gnu/c_locale.h, __gnu_cxx::__uselocale is used. I had to remove
__gnu_cxx:: scope to get it worked.)
2) How to use libintl
It took me a while to recognize newlocale is redefined to
libintl_newlocale, which cause linker error. So I undefined newlocale
and setlocale, which are redeinfed to libintl_xxx version in libintl.h
(They are two libintls. one is provided in gettext package in macports,
and the other is what comes with the gcc distribution)
3) Generic symbols for xlocale availability
If many ifdefs like
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
are defined like
#if HAS_XLOCALE_H
many codes can be shared with gnu directory. Most of my work was to get
codes inside those ifdef compiled.
--
Takeshi Kobayakawa
tskoba@tskoba.mydns.jp
More information about the Libstdc++
mailing list