[libcxx-commits] [libcxx] [libcxx] don't `#include <cwchar>` if wide chars aren't enabled (PR #99911)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jul 22 11:10:08 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Ties Stuij (stuij)

<details>
<summary>Changes</summary>

Pull request #<!-- -->96032 unconditionall adds the `cwchar` include in the `format` umbrella header. However support for wchar_t can be disabled in the build system (LIBCXX_ENABLE_WIDE_CHARACTERS).

This patch guards against inclusion of `cwchar` in `format` by checking the `_LIBCPP_HAS_NO_WIDE_CHARACTERS` define.

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


1 Files Affected:

- (modified) libcxx/include/format (+6-6) 


``````````diff
diff --git a/libcxx/include/format b/libcxx/include/format
index c3f2b45f0f730..af5391ccea9dc 100644
--- a/libcxx/include/format
+++ b/libcxx/include/format
@@ -237,21 +237,21 @@ namespace std {
 #  include <cstdint>
 #  include <cstdlib>
 #  include <cstring>
-#  include <cwchar>
 #  include <initializer_list>
 #  include <limits>
+#  include <locale>
 #  include <new>
 #  include <optional>
+#  include <queue>
+#  include <stack>
 #  include <stdexcept>
 #  include <string>
 #  include <string_view>
 #  include <tuple>
-#endif
 
-#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
-#  include <locale>
-#  include <queue>
-#  include <stack>
+#if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+#  include <cwchar>
+#endif
 #endif
 
 #endif // _LIBCPP_FORMAT

``````````

</details>


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


More information about the libcxx-commits mailing list