[libcxx-commits] [libcxx] [libcxx] fix missing `__get_locale_encoding()` for OpenBSD (PR #228306)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Oct 1 19:17:11 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Alex Rønne Petersen (alexrp)

<details>
<summary>Changes</summary>

Fixes errors like this:

    /home/alexrp/Sources/ziglang/zig-llvm23/lib/libcxx/src/text_encoding.cpp:34:43: error: no member named '__get_locale_encoding' in namespace
        'std::__locale'
    34 |     return __make_text_encoding(__locale::__get_locale_encoding(static_cast<__locale::__locale_t>(0)));
        |                                           ^~~~~~~~~~~~~~~~~~~~~
    /home/alexrp/Sources/ziglang/zig-llvm23/lib/libcxx/src/text_encoding.cpp:48:41: error: no member named '__get_locale_encoding' in namespace
        'std::__locale'
    48 |   return __make_text_encoding(__locale::__get_locale_encoding(__l));
        |                                         ^~~~~~~~~~~~~~~~~~~~~
    2 errors generated.

---
Full diff: https://github.com/llvm/llvm-project/pull/228306.diff


1 Files Affected:

- (modified) libcxx/include/__locale_dir/support/openbsd.h (+7) 


``````````diff
diff --git a/libcxx/include/__locale_dir/support/openbsd.h b/libcxx/include/__locale_dir/support/openbsd.h
index 369b8e652689b..b22cdf38b10ec 100644
--- a/libcxx/include/__locale_dir/support/openbsd.h
+++ b/libcxx/include/__locale_dir/support/openbsd.h
@@ -24,6 +24,9 @@
 #  include <wchar.h>
 #  include <wctype.h>
 #endif
+#if defined(_LIBCPP_BUILDING_LIBRARY)
+#  include <langinfo.h>
+#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
@@ -74,6 +77,10 @@ inline __lconv_t* __localeconv(__locale_t& __loc) {
   __locale_guard __current(__loc);
   return ::localeconv();
 }
+
+inline _LIBCPP_HIDE_FROM_ABI const char* __get_locale_encoding(__locale_t __loc) {
+    return ::nl_langinfo_l(CODESET, __loc);
+}
 #endif // _LIBCPP_BUILDING_LIBRARY
 
 //

``````````

</details>


https://github.com/llvm/llvm-project/pull/228306


More information about the libcxx-commits mailing list