This is the mail archive of the mailing list for the glibc project.

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

Re: The behavor of printing out libc message catalog without calling setlocale()

GOTO Masanori wrote on 2000-11-07 18:40 UTC:
> > Second, calling setlocale() is always
> > necessary if any of the locale-related environment variables is to be
> > used (LC_ALL, LC_xxx, LANG).
> What standard is it described?

ISO/IEC 9899:1999 (ISO C99) says in

       [#3] A  value  of  "C"  for  locale  specifies  the  minimal
       environment  for  C  translation;  a  value of "" for locale
       specifies the  locale-specific  native  environment.   Other
       implementation-defined  strings  may be passed as the second
       argument to setlocale.

       [#4] At program startup, the equivalent of

               setlocale(LC_ALL, "C");

       is executed.

> If calling setlocale() is needed anytime when we set locale-related 
> env variables, we must write setlocale() into hello.c ?! 

If you want the locale-dependent functions (such as gettext) used in
hello.c to follow any locale other than "C", then you definitely have to
call setlocale().

> # Why don't you have setlocale(LC_ALL,"") in crt0.o? :-)

Because this would be in violation of the above paragraph of ISO C, and
we like to obey the holly scripture.


Markus G. Kuhn, Computer Laboratory, University of Cambridge, UK
Email: mkuhn at,  WWW: <>

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