[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: localename: add support for musl libc
From: |
Bruno Haible |
Subject: |
Re: localename: add support for musl libc |
Date: |
Sun, 25 Feb 2018 11:17:08 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-112-generic; KDE/5.18.0; x86_64; ; ) |
Hi Assaf,
> > +# elif defined __linux__ && HAVE_LANGINFO_H && defined NL_LOCALE_NAME
> > + /* musl libc */
>
> A tiny comment about the comment :)
>
> You wrote "musl libc", but what the "elif defined ..." is something like
> "linux but not glibc, with langinfo.h" - which could (in theory) be
> something other than musl-libc.
Yes, that's it. The refusal of the musl people to define a symbol such
as __MUSL__ [1] makes it hard to write future-proof code. If someone else
creates a platform that shares the same superficial characteristics
(runs on Linux, has <langinfo.h> and NL_LOCALE_NAME) but behaves
differently, we will accidentally run into the code intended for musl
on that platform. Whereas the fallback code (return "" in this case)
would be safer: it would make the unit test fail, but it would not
lead to a compilation error or to a code dump.
And if that platform does not have an identifiying macro either, we
really got a problem how to distinguish the two.
Bruno
[1] https://wiki.musl-libc.org/faq.html