Multiple std::messages instances for different text domains

Sam Varshavchik mrsam@courier-mta.com
Sun Jun 14 14:12:00 GMT 2009


I'm looking at the implementation of std::messages 
(libstdc++-v3/config/locale/gnu), and I'm trying to understand the 
following.

>From what I can figure out, do_open() calls textdomain(), and do_get() then 
calls gettext() to retrieve the messages.

So, if there are two std::messages facets in use, and the first one's open() 
method gets invoked specifying text domain X, and the second one's open() 
method gets invoked specifying text domain Y, then the first instance's 
get() method will no longer work, since the gettext() function now uses text 
domain Y, rather than X.

Invoking libintl directly, shared libraries can work with their own message 
catalogs without affecting the main application by using dgettext() instead 
of gettext(). As far as I can see, I can't use std::messages facets in my 
shared library, doing so will mess up the application, if it also uses 
gettext(), either directly or via std::messages.

I think that do_open() should, instead, save the text domain in the facet, 
and do_get() should use dgettext() instead of gettext().

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20090614/1288858f/attachment.sig>


More information about the Libstdc++ mailing list