[libcxx-commits] [libcxx] [libc++] Skip including langinfo.h on Android (PR #223749)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Sep 15 09:04:17 PDT 2026
https://github.com/google-yfyang created https://github.com/llvm/llvm-project/pull/223749
A previous change unconditionally includes <langinfo.h> while on Android, libc++ hardcodes "UTF-8" in __get_locale_encoding() and never uses anything from langinfo.
Android Bionic'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;
```
>From 8ec983442eb8123f280355f4c0cb9f0a6dad0377 Mon Sep 17 00:00:00 2001
From: google-yfyang <yfyang at google.com>
Date: Tue, 15 Sep 2026 12:00:37 -0400
Subject: [PATCH] [libc++] Skip including langinfo.h on Android
---
libcxx/include/__locale_dir/support/linux.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libcxx/include/__locale_dir/support/linux.h b/libcxx/include/__locale_dir/support/linux.h
index 74abf5ab7c598d..fc8dbf0ed01aa0 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(__ANDROID__)
+# include <langinfo.h>
+#endif
#include <stdarg.h>
#include <string.h>
#include <time.h>
More information about the libcxx-commits
mailing list