From e2050b9b35acc79ae47f607c5c54baf805cfa734 Mon Sep 17 00:00:00 2001 From: David Justo Date: Fri, 24 Oct 2025 16:00:14 -0700 Subject: [PATCH 1/3] check for `_STATIC_INLINE_UCRT_FUNCTIONS` to determine if UCRT functions can be naively exported through modules --- stl/inc/ctime | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/stl/inc/ctime b/stl/inc/ctime index ae2f152edc4..3714b5beb70 100644 --- a/stl/inc/ctime +++ b/stl/inc/ctime @@ -29,7 +29,11 @@ _EXPORT_STD using _CSTD strftime; _EXPORT_STD using _CSTD timespec; #endif // _HAS_CXX17 -#ifdef _BUILD_STD_MODULE // TRANSITION, OS-33790456; `template ` avoids ambiguity +// `_STATIC_INLINE_UCRT_FUNCTIONS` is exposed by the UCRT starting on Windows SDK `10.0.26100.6901`. +// When set to `1`, several UCRT functions are declared as `static inline` (for historical compatibility), +// preventing them from being naively exported through modules. +// In that case, we use templates to shadow their name, allowing us forcibly to export them. +#if defined(_STATIC_INLINE_UCRT_FUNCTIONS) && _STATIC_INLINE_UCRT_FUNCTIONS == 1 _STL_DISABLE_DEPRECATED_WARNING _EXPORT_STD template @@ -75,7 +79,7 @@ _Check_return_ inline int __CRTDECL timespec_get(_Out_ timespec* const _Ts, _In_ _STL_RESTORE_DEPRECATED_WARNING #else // ^^^ workaround / no workaround vvv -// _EXPORT_STD has no effect while the workaround is present. +// _EXPORT_STD has no effect when `_BUILD_STD_MODULE` is not defined. _EXPORT_STD using _CSTD ctime; _EXPORT_STD using _CSTD difftime; _EXPORT_STD using _CSTD gmtime; From 8005ad62c98f86773a667804e8fb6dc64887d861 Mon Sep 17 00:00:00 2001 From: David Justo Date: Mon, 27 Oct 2025 14:29:37 -0700 Subject: [PATCH 2/3] fix: workaround should be active on older Windows SDKs and only when building the `std` module To ensure its active under older Windows SDKs, we make sure it runs when `_STATIC_INLINE_UCRT_FUNCTIONS` is not defined. To ensure it's present only when building the `std` module, we check for `_BUILD_STD_MODULE`. Co-authored-by: S. B. Tam --- stl/inc/ctime | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/ctime b/stl/inc/ctime index 3714b5beb70..d3952fda288 100644 --- a/stl/inc/ctime +++ b/stl/inc/ctime @@ -33,7 +33,7 @@ _EXPORT_STD using _CSTD timespec; // When set to `1`, several UCRT functions are declared as `static inline` (for historical compatibility), // preventing them from being naively exported through modules. // In that case, we use templates to shadow their name, allowing us forcibly to export them. -#if defined(_STATIC_INLINE_UCRT_FUNCTIONS) && _STATIC_INLINE_UCRT_FUNCTIONS == 1 +#if defined(_BUILD_STD_MODULE) && (!defined(_STATIC_INLINE_UCRT_FUNCTIONS) || _STATIC_INLINE_UCRT_FUNCTIONS == 1) _STL_DISABLE_DEPRECATED_WARNING _EXPORT_STD template From da02b091ea31e4d2264829adf1c2d68a71c18a4a Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Tue, 18 Nov 2025 16:15:09 -0800 Subject: [PATCH 3/3] Improve comments. --- stl/inc/ctime | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/stl/inc/ctime b/stl/inc/ctime index d3952fda288..5a33180dc43 100644 --- a/stl/inc/ctime +++ b/stl/inc/ctime @@ -29,10 +29,10 @@ _EXPORT_STD using _CSTD strftime; _EXPORT_STD using _CSTD timespec; #endif // _HAS_CXX17 -// `_STATIC_INLINE_UCRT_FUNCTIONS` is exposed by the UCRT starting on Windows SDK `10.0.26100.6901`. +// `_STATIC_INLINE_UCRT_FUNCTIONS` is exposed by the UCRT starting with Windows SDK 10.0.26100.6901. // When set to `1`, several UCRT functions are declared as `static inline` (for historical compatibility), -// preventing them from being naively exported through modules. -// In that case, we use templates to shadow their name, allowing us forcibly to export them. +// preventing them from being directly exported by modules. In that case (and when an older UCRT doesn't define +// the macro), we use templates to shadow their names, allowing us to export the templates as an approximation. #if defined(_BUILD_STD_MODULE) && (!defined(_STATIC_INLINE_UCRT_FUNCTIONS) || _STATIC_INLINE_UCRT_FUNCTIONS == 1) _STL_DISABLE_DEPRECATED_WARNING @@ -79,7 +79,6 @@ _Check_return_ inline int __CRTDECL timespec_get(_Out_ timespec* const _Ts, _In_ _STL_RESTORE_DEPRECATED_WARNING #else // ^^^ workaround / no workaround vvv -// _EXPORT_STD has no effect when `_BUILD_STD_MODULE` is not defined. _EXPORT_STD using _CSTD ctime; _EXPORT_STD using _CSTD difftime; _EXPORT_STD using _CSTD gmtime;