[libcxx-commits] [libcxx] [libc++] Fix std modules compile errors caused by <ctime> functions on Windows (PR #174136)
Martin Storsjö via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Jan 3 13:55:53 PST 2026
================
@@ -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(_STATIC_INLINE_UCRT_FUNCTIONS) && _STATIC_INLINE_UCRT_FUNCTIONS == 0)
using std::ctime _LIBCPP_USING_IF_EXISTS;
----------------
mstorsjo wrote:
Won't this cause non-Windows builds to not export these symbols in the modules at all?
Also - this is only an issue in MSVC style builds; in mingw style builds (which also are windows, but doesn't use Microsoft's headers) this is not an issue. So I would suggest you amend this into `#if !defined(_MSC_VER) || (defined(_STATIC_INLINE_UCRT_FUNCTIONS) && _STATIC_INLINE_UCRT_FUNCTIONS == 0)`.
https://github.com/llvm/llvm-project/pull/174136
More information about the libcxx-commits
mailing list