This should fix a build failure on Windows which lacks <langinfo.h>,
from which we use nl_langinfo() to obtain the radix character of the
current locale. (We can't use the more portable localeconv() from
<clocale> to obtain the radix character of the current locale here
because it's not thread-safe, unfortunately.)
This change means that on Windows and other such platforms, we'll just
always assume the radix character used by printf is '.' when formatting
a long double through it.
libstdc++-v3/ChangeLog:
PR libstdc++/98374
* src/c++17/floating_to_chars.cc: Guard include of <langinfo.h>
with __has_include.
(__floating_to_chars_precision) [!defined(RADIXCHAR)]: Don't
attempt to obtain the radix character of the current locale,
just assume it's '.'.
#include <cmath>
#include <cstdio>
#include <cstring>
-#include <langinfo.h>
+#if __has_include(<langinfo.h>)
+# include <langinfo.h> // for nl_langinfo
+#endif
#include <optional>
#include <string_view>
#include <type_traits>
// to handle a radix point that's different from '.'.
char radix[6] = {'.', '\0', '\0', '\0', '\0', '\0'};
if (effective_precision > 0)
+#ifdef RADIXCHAR
// ???: Can nl_langinfo() ever return null?
if (const char* const radix_ptr = nl_langinfo(RADIXCHAR))
{
// UTF-8 character) wide.
__glibcxx_assert(radix[4] == '\0');
}
+#endif
// Compute straightforward upper bounds on the output length.
int output_length_upper_bound;