[libcxx-commits] [libcxx] [libc++] Fix std modules compile errors caused by <ctime> functions on Windows (PR #174136)

via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jan 4 10:42:22 PST 2026


https://github.com/siradam7th updated https://github.com/llvm/llvm-project/pull/174136

>From 1df9e79d874de9c4939e37a3d7d6dae0cb05a5c3 Mon Sep 17 00:00:00 2001
From: siradam7th <siradam7th at users.noreply.github.com>
Date: Sun, 4 Jan 2026 19:38:20 +0100
Subject: [PATCH] fix std modules on Windows caused by <ctime> functions

---
 libcxx/modules/std.compat/ctime.inc | 7 +++++++
 libcxx/modules/std/ctime.inc        | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/libcxx/modules/std.compat/ctime.inc b/libcxx/modules/std.compat/ctime.inc
index eba8234a08969..b529bcfd5e336 100644
--- a/libcxx/modules/std.compat/ctime.inc
+++ b/libcxx/modules/std.compat/ctime.inc
@@ -17,6 +17,12 @@ export {
 
   using ::asctime _LIBCPP_USING_IF_EXISTS;
   using ::clock _LIBCPP_USING_IF_EXISTS;
+
+// NOTE: UCRT before Windows SDK 10.0.26100.6901 defines the <ctime> functions
+// with 'static' so we cannot export them, but later versions fixed it and now
+// define a macro we can use to detect older UCRT without the fix and we use it
+// to avoid exporting them in order to compile without errors
+#if !defined(_MSC_VER) || (defined(_STATIC_INLINE_UCRT_FUNCTIONS) && _STATIC_INLINE_UCRT_FUNCTIONS == 0)
   using ::ctime _LIBCPP_USING_IF_EXISTS;
   using ::difftime _LIBCPP_USING_IF_EXISTS;
   using ::gmtime _LIBCPP_USING_IF_EXISTS;
@@ -25,4 +31,5 @@ export {
   using ::strftime _LIBCPP_USING_IF_EXISTS;
   using ::time _LIBCPP_USING_IF_EXISTS;
   using ::timespec_get _LIBCPP_USING_IF_EXISTS;
+#endif
 } // export
diff --git a/libcxx/modules/std/ctime.inc b/libcxx/modules/std/ctime.inc
index 5bfa61917e5f2..12dc55aa04b52 100644
--- a/libcxx/modules/std/ctime.inc
+++ b/libcxx/modules/std/ctime.inc
@@ -17,6 +17,12 @@ export namespace std {
 
   using std::asctime _LIBCPP_USING_IF_EXISTS;
   using std::clock _LIBCPP_USING_IF_EXISTS;
+
+// NOTE: UCRT before Windows SDK 10.0.26100.6901 defines the <ctime> functions
+// with 'static' so we cannot export them, but later versions fixed it and now
+// define a macro we can use to detect older UCRT without the fix and we use it
+// to avoid exporting them in order to compile without errors
+#if !defined(_MSC_VER) || (defined(_STATIC_INLINE_UCRT_FUNCTIONS) && _STATIC_INLINE_UCRT_FUNCTIONS == 0)
   using std::ctime _LIBCPP_USING_IF_EXISTS;
   using std::difftime _LIBCPP_USING_IF_EXISTS;
   using std::gmtime _LIBCPP_USING_IF_EXISTS;
@@ -25,4 +31,5 @@ export namespace std {
   using std::strftime _LIBCPP_USING_IF_EXISTS;
   using std::time _LIBCPP_USING_IF_EXISTS;
   using std::timespec_get _LIBCPP_USING_IF_EXISTS;
+#endif
 } // namespace std



More information about the libcxx-commits mailing list