Skip to content

Conversation

@vonosmas
Copy link
Contributor

<wchar.h> should at least include the forward declaration of struct tm,
since it's needed for the wcsftime declaration (also, see https://man7.org/linux/man-pages/man0/wchar.h.0p.html).

Even though we don't yet have wcsftime, some downstream users (notably - libcxx) expects to see struct tm
declaration there, to re-declare it under std namespace:

using ::tm _LIBCPP_USING_IF_EXISTS;

So, add this type declaration to llvm-libc version of wchar.h now.

@vonosmas vonosmas requested a review from lntue October 30, 2025 23:06
@llvmbot llvmbot added the libc label Oct 30, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 30, 2025

@llvm/pr-subscribers-libc

Author: Alexey Samsonov (vonosmas)

Changes

&lt;wchar.h&gt; should at least include the forward declaration of struct tm,
since it's needed for the wcsftime declaration (also, see https://man7.org/linux/man-pages/man0/wchar.h.0p.html).

Even though we don't yet have wcsftime, some downstream users (notably - libcxx) expects to see struct tm
declaration there, to re-declare it under std namespace:

using ::tm _LIBCPP_USING_IF_EXISTS;

So, add this type declaration to llvm-libc version of wchar.h now.


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

1 Files Affected:

  • (modified) libc/include/wchar.yaml (+1)
diff --git a/libc/include/wchar.yaml b/libc/include/wchar.yaml
index c8b9e21b56b28..77af0fd4219e7 100644
--- a/libc/include/wchar.yaml
+++ b/libc/include/wchar.yaml
@@ -6,6 +6,7 @@ macros:
 types:
   - type_name: FILE
   - type_name: size_t
+  - type_name: struct_tm
   - type_name: wint_t
   - type_name: wchar_t
   - type_name: mbstate_t

@vonosmas vonosmas merged commit 42a8ff8 into llvm:main Oct 31, 2025
18 of 19 checks passed
DEBADRIBASAK pushed a commit to DEBADRIBASAK/llvm-project that referenced this pull request Nov 3, 2025
`<wchar.h>` should at least include the forward declaration of `struct tm`,
since it's needed for the `wcsftime` declaration (also, see
https://man7.org/linux/man-pages/man0/wchar.h.0p.html).

Even though we don't yet have `wcsftime`, some downstream users (notably
- libcxx) expects to see `struct tm` declaration there, to re-declare it under
`std` namespace:
https://github.com/llvm/llvm-project/blob/c46bfed1a484d30cd251a9a225649d74e3bf0af5/libcxx/include/cwchar#L135

So, add this type declaration to llvm-libc version of `wchar.h` now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants