[libcxx-commits] [libcxx] 91a8753 - [libc++] Skip including langinfo.h when unused (#223749)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Sep 16 08:48:15 PDT 2026
Author: google-yfyang
Date: 2026-09-16T11:48:10-04:00
New Revision: 91a87531f26b989863517e07f0648733029c7cfe
URL: https://github.com/llvm/llvm-project/commit/91a87531f26b989863517e07f0648733029c7cfe
DIFF: https://github.com/llvm/llvm-project/commit/91a87531f26b989863517e07f0648733029c7cfe.diff
LOG: [libc++] Skip including langinfo.h when unused (#223749)
A previous change unconditionally includes <langinfo.h>.
__get_locale_encoding() only uses langinfo when compiling shared
libraries, and hardcodes "UTF-8" on Android.
glibc's <langinfo.h> defines POSIX nl_item constants as raw numeric
preprocessor macros (#define ERA 46).
This causes Bionic's #define ERA 46 leaks into C++ translation units on
Android and fails the compilation with:
```
error: expected member name or ';' after declaration specifiers
static constexpr typename ERA = random_value;
```
Added:
Modified:
libcxx/include/__locale_dir/support/linux.h
Removed:
################################################################################
diff --git a/libcxx/include/__locale_dir/support/linux.h b/libcxx/include/__locale_dir/support/linux.h
index 74abf5ab7c598..69f494987e4e3 100644
--- a/libcxx/include/__locale_dir/support/linux.h
+++ b/libcxx/include/__locale_dir/support/linux.h
@@ -17,7 +17,9 @@
#include <cstdio>
#include <cstdlib>
#include <ctype.h>
-#include <langinfo.h>
+#if defined(_LIBCPP_BUILDING_LIBRARY)
+# include <langinfo.h>
+#endif
#include <stdarg.h>
#include <string.h>
#include <time.h>
More information about the libcxx-commits
mailing list