[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gettext 0.11.2: setlocale() ?
From: |
Paul Eggert |
Subject: |
Re: gettext 0.11.2: setlocale() ? |
Date: |
Sun, 28 Apr 2002 02:05:16 -0700 (PDT) |
> From: "Paul D. Smith" <address@hidden>
> Date: 28 Apr 2002 01:02:53 -0400
>
> I'm testing my new installation of gettext on various platforms; I'm
> using the "external" method for Gettext support. On Linux, where
> libintl etc. exist, everything works great.
>
> On Solaris, where it doesn't, I get a compile error at the line:
>
> setlocale (LC_ALL, "");
>
> due to LC_ALL not being defined (and, presumably if I fix that, for
> setlocale() not being defined.
> I can see a number of ways to fix this: add it as an empty macro to
> gettext.h;
That wouldn't be quite right, as setlocale and gettext can be turned
on and off independently. For example, setlocale can have an effect
even if gettext is disabled (e.g. with --disable-nls).
> test the HAVE_SETLOCALE config.h variable which the
> gettext.m4 macros already set up for us via configure, and don't compile
> that line if it's not set
That will work OK, but it means you need to clutter up your code for
each main program.
> test HAVE_LOCALE_H and make setlocale() a
> macro expanding to empty (this is what diffutils does).
That's the _right_ way. (:-)
This simplifies the code, since you can do this in a single .h file
and have every main program include it.
> Nothing in the gettext manual discusses this;
The gettext manual does briefly say somewhere that you need to include
<locale.h>, but admittedly this is pretty terse and it would be nice
to have a longer discussion. The diffutils approach is to put:
#if HAVE_LOCALE_H
# include <locale.h>
#else
# define setlocale(category, locale)
#endif
#include <gettext.h>
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
into an include file, and it might not hurt to put this into the
gettext manual.
While we're on the subject, I suspect that the gettext manual is aimed
at hosted implementations conforming to C89 or better; this should
probably be mentioned in the gettext manual somewhere. (Such
implementations must have setlocale and <locale.h>.)