When building the C++23 std modules, at least with libc++, the
C++ module needs to reexport a number of standard C functions.

The regular libc++ headers (the ones used even if not using
C++ modules) do this, essentially:

    namespace std {
        using ::ctime;
    }

Thus reexporting the regular C function ctime within the std
namespace.

When building libc++ as a module, this function gets emitted as
part of the C++ std module, like this:

    export namespace std {
        using std::ctime;
    }

This tries to export the function as part of the C++ module. In the
case of our inline functions, this errors out if the inline functions
are static inline:

    <prefix>/share/libc++/v1/std/ctime.inc:20:14: error: using declaration 
referring to 'ctime' with internal linkage cannot be exported
       20 |   using std::ctime;
          |              ^
    <prefix>/x86_64-w64-mingw32/include/time.h:267:29: note: target of using 
declaration
      267 | static __inline char *__CRTDECL ctime(const time_t *_Time) { return 
_ctime64(_Time); }
          |                                 ^

Therefore, prefer using the __mingw_ovr macro for these inline
declarations. This macro expands to regular plain (non-static)
inline in C++ mode, while it still expands to static inline in C mode.

Signed-off-by: Martin Storsjö <mar...@martin.st>
---
 mingw-w64-headers/crt/time.h  | 48 +++++++++++++++++------------------
 mingw-w64-headers/crt/wchar.h |  2 +-
 2 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/mingw-w64-headers/crt/time.h b/mingw-w64-headers/crt/time.h
index d70a70717..f8401903c 100644
--- a/mingw-w64-headers/crt/time.h
+++ b/mingw-w64-headers/crt/time.h
@@ -241,33 +241,33 @@ extern "C" {
 #ifndef RC_INVOKED
 
 #ifdef _USE_32BIT_TIME_T
-static __inline time_t __CRTDECL time(time_t *_Time) { return _time32(_Time); }
+__mingw_ovr time_t __CRTDECL time(time_t *_Time) { return _time32(_Time); }
 #ifdef _UCRT
-static __inline int __CRTDECL timespec_get(struct timespec* _Ts, int _Base) { 
return _timespec32_get((struct _timespec32*)_Ts, _Base); }
-#endif
-static __inline double __CRTDECL difftime(time_t _Time1,time_t _Time2)  { 
return _difftime32(_Time1,_Time2); }
-static __inline struct tm *__CRTDECL localtime(const time_t *_Time) { return 
_localtime32(_Time); }
-static __inline errno_t __CRTDECL localtime_s(struct tm *_Tm,const time_t 
*_Time) { return _localtime32_s(_Tm,_Time); }
-static __inline struct tm *__CRTDECL gmtime(const time_t *_Time) { return 
_gmtime32(_Time); }
-static __inline errno_t __CRTDECL gmtime_s(struct tm *_Tm, const time_t 
*_Time)   { return _gmtime32_s(_Tm, _Time); }
-static __inline char *__CRTDECL ctime(const time_t *_Time) { return 
_ctime32(_Time); }
-static __inline errno_t __CRTDECL ctime_s(char *_Buf,size_t _SizeInBytes,const 
time_t *_Time) { return _ctime32_s(_Buf,_SizeInBytes,_Time); }
-static __inline time_t __CRTDECL mktime(struct tm *_Tm) { return 
_mktime32(_Tm); }
-static __inline time_t __CRTDECL _mkgmtime(struct tm *_Tm) { return 
_mkgmtime32(_Tm); }
+__mingw_ovr int __CRTDECL timespec_get(struct timespec* _Ts, int _Base) { 
return _timespec32_get((struct _timespec32*)_Ts, _Base); }
+#endif
+__mingw_ovr double __CRTDECL difftime(time_t _Time1,time_t _Time2)  { return 
_difftime32(_Time1,_Time2); }
+__mingw_ovr struct tm *__CRTDECL localtime(const time_t *_Time) { return 
_localtime32(_Time); }
+__mingw_ovr errno_t __CRTDECL localtime_s(struct tm *_Tm,const time_t *_Time) 
{ return _localtime32_s(_Tm,_Time); }
+__mingw_ovr struct tm *__CRTDECL gmtime(const time_t *_Time) { return 
_gmtime32(_Time); }
+__mingw_ovr errno_t __CRTDECL gmtime_s(struct tm *_Tm, const time_t *_Time)   
{ return _gmtime32_s(_Tm, _Time); }
+__mingw_ovr char *__CRTDECL ctime(const time_t *_Time) { return 
_ctime32(_Time); }
+__mingw_ovr errno_t __CRTDECL ctime_s(char *_Buf,size_t _SizeInBytes,const 
time_t *_Time) { return _ctime32_s(_Buf,_SizeInBytes,_Time); }
+__mingw_ovr time_t __CRTDECL mktime(struct tm *_Tm) { return _mktime32(_Tm); }
+__mingw_ovr time_t __CRTDECL _mkgmtime(struct tm *_Tm) { return 
_mkgmtime32(_Tm); }
 #else
-static __inline time_t __CRTDECL time(time_t *_Time) { return _time64(_Time); }
+__mingw_ovr time_t __CRTDECL time(time_t *_Time) { return _time64(_Time); }
 #ifdef _UCRT
-static __inline int __CRTDECL timespec_get(struct timespec* _Ts, int _Base) { 
return _timespec64_get((struct _timespec64*)_Ts, _Base); }
-#endif
-static __inline double __CRTDECL difftime(time_t _Time1,time_t _Time2) { 
return _difftime64(_Time1,_Time2); }
-static __inline struct tm *__CRTDECL localtime(const time_t *_Time) { return 
_localtime64(_Time); }
-static __inline errno_t __CRTDECL localtime_s(struct tm *_Tm,const time_t 
*_Time) { return _localtime64_s(_Tm,_Time); }
-static __inline struct tm *__CRTDECL gmtime(const time_t *_Time) { return 
_gmtime64(_Time); }
-static __inline errno_t __CRTDECL gmtime_s(struct tm *_Tm, const time_t 
*_Time) { return _gmtime64_s(_Tm, _Time); }
-static __inline char *__CRTDECL ctime(const time_t *_Time) { return 
_ctime64(_Time); }
-static __inline errno_t __CRTDECL ctime_s(char *_Buf,size_t _SizeInBytes,const 
time_t *_Time) { return _ctime64_s(_Buf,_SizeInBytes,_Time); }
-static __inline time_t __CRTDECL mktime(struct tm *_Tm) { return 
_mktime64(_Tm); }
-static __inline time_t __CRTDECL _mkgmtime(struct tm *_Tm) { return 
_mkgmtime64(_Tm); }
+__mingw_ovr int __CRTDECL timespec_get(struct timespec* _Ts, int _Base) { 
return _timespec64_get((struct _timespec64*)_Ts, _Base); }
+#endif
+__mingw_ovr double __CRTDECL difftime(time_t _Time1,time_t _Time2) { return 
_difftime64(_Time1,_Time2); }
+__mingw_ovr struct tm *__CRTDECL localtime(const time_t *_Time) { return 
_localtime64(_Time); }
+__mingw_ovr errno_t __CRTDECL localtime_s(struct tm *_Tm,const time_t *_Time) 
{ return _localtime64_s(_Tm,_Time); }
+__mingw_ovr struct tm *__CRTDECL gmtime(const time_t *_Time) { return 
_gmtime64(_Time); }
+__mingw_ovr errno_t __CRTDECL gmtime_s(struct tm *_Tm, const time_t *_Time) { 
return _gmtime64_s(_Tm, _Time); }
+__mingw_ovr char *__CRTDECL ctime(const time_t *_Time) { return 
_ctime64(_Time); }
+__mingw_ovr errno_t __CRTDECL ctime_s(char *_Buf,size_t _SizeInBytes,const 
time_t *_Time) { return _ctime64_s(_Buf,_SizeInBytes,_Time); }
+__mingw_ovr time_t __CRTDECL mktime(struct tm *_Tm) { return _mktime64(_Tm); }
+__mingw_ovr time_t __CRTDECL _mkgmtime(struct tm *_Tm) { return 
_mkgmtime64(_Tm); }
 #endif
 
 #endif /* !RC_INVOKED */
diff --git a/mingw-w64-headers/crt/wchar.h b/mingw-w64-headers/crt/wchar.h
index b1c103686..c3bbbcc23 100644
--- a/mingw-w64-headers/crt/wchar.h
+++ b/mingw-w64-headers/crt/wchar.h
@@ -1439,7 +1439,7 @@ int vsnwprintf (wchar_t *__stream, size_t __n, const 
wchar_t *__format, __builti
   int __cdecl fwide(FILE *stream,int mode);
 #if defined(_UCRT) || defined(__LARGE_MBSTATE_T)
   /* With UCRT, mbsinit is only available as inline. */
-  __mingw_static_ovr int __cdecl mbsinit(const mbstate_t *_P) { return (!_P || 
_P->_Wchar == 0); }
+  __mingw_ovr int __cdecl mbsinit(const mbstate_t *_P) { return (!_P || 
_P->_Wchar == 0); }
 #else
   int __cdecl mbsinit(const mbstate_t *ps);
 #endif
-- 
2.34.1



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to