[libcxx-commits] [libcxx] [libc++] Fix C++23 standard modules when using with `clang-cl` on Windows (PR #148992)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 22 05:35:41 PDT 2025


================
@@ -14,15 +14,57 @@ export {
 
   using ::timespec _LIBCPP_USING_IF_EXISTS;
   using ::tm _LIBCPP_USING_IF_EXISTS;
-
   using ::asctime _LIBCPP_USING_IF_EXISTS;
   using ::clock _LIBCPP_USING_IF_EXISTS;
+  using ::strftime _LIBCPP_USING_IF_EXISTS;
+
+#ifndef _LIBCPP_ABI_VCRUNTIME
   using ::ctime _LIBCPP_USING_IF_EXISTS;
   using ::difftime _LIBCPP_USING_IF_EXISTS;
   using ::gmtime _LIBCPP_USING_IF_EXISTS;
   using ::localtime _LIBCPP_USING_IF_EXISTS;
   using ::mktime _LIBCPP_USING_IF_EXISTS;
-  using ::strftime _LIBCPP_USING_IF_EXISTS;
   using ::time _LIBCPP_USING_IF_EXISTS;
   using ::timespec_get _LIBCPP_USING_IF_EXISTS;
+#endif
+
+// A workaround for UCRT because it defines these functions
+// as static and that causes the error "internal linkage cannot be exported"
+#ifdef _LIBCPP_ABI_VCRUNTIME
+
+  template <int = 0>
+  inline char* __CRTDECL ctime(_In_ time_t const* const _Time) noexcept {
+    return _ctime64(_Time);
+  }
+
+  template <int = 0>
+  inline double __CRTDECL difftime(_In_ time_t const _Time1, _In_ time_t const _Time2) noexcept {
+    return _difftime64(_Time1, _Time2);
+  }
+
+  template <int = 0>
+  inline tm* __CRTDECL gmtime(_In_ time_t const* const _Time) noexcept {
+    return _gmtime64(_Time);
+  }
+
+  template <int = 0>
+  inline tm* __CRTDECL localtime(_In_ time_t const* const _Time) noexcept {
+    return _localtime64(_Time);
+  }
+
+  template <int = 0>
+  inline time_t __CRTDECL mktime(_Inout_ tm* const _Tm) noexcept {
+    return _mktime64(_Tm);
+  }
+
+  template <int = 0>
+  inline time_t __CRTDECL time(_Out_opt_ time_t* const _Time) noexcept {
+    return _time64(_Time);
+  }
+
+  template <int = 0>
+  inline int __CRTDECL timespec_get(_Out_ timespec* const _Ts, _In_ int const _Base) noexcept {
+    return _timespec64_get(reinterpret_cast<_timespec64*>(_Ts), _Base);
+  }
+#endif
----------------
philnik777 wrote:

That is definitely more palatable. I'm not sure I'd approve it; I'll have to think about that a bit more I think.

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


More information about the libcxx-commits mailing list