Hi,

If trying to build libc++'s C++23 std module on top of the mingw
headers, this currently fails for a number of cases where the
std module wants to reexport a number of functions from the
underlying libc. In the case of mingw-w64's headers, many standard
C functions are implemented as inline functions, and this fails
if those functions are "static inline". Plain C++ "inline" works
fine though.

We do have the macro __mingw_ovr, which expands to "inline" in C++
mode, and "static inline" in C mode. This patchset avoids
redefining __mingw_ovr in swprintf.inl and wchar.h, and applies
this attribute instead of hardcoded "static inline" on a bunch
of time functions, and mbsinit.

With these patches in place, it's possible to build the libc++
C++23 std module on top of our headers.

I guess non-static C++ inline can be problematic for functions
that can be redefined based on macros, like _USE_32BIT_TIME_T
or __USE_MINGW_ANSI_STDIO; if two object files in the same
link both use the same standard C functions (for regular
compilation and linking, not specific to C++ modules), but with
these defines set differently, both object files will have their
own conflicting definition of the inline function, and the linker
is free to pick either of them and use it for both cases.

On the other hand, given the widespread use of __mingw_ovr,
this might be a preexisting issue in any case. But then again,
due to headers like swprintf.inl and wchar.h redefining __mingw_ovr,
it's possible that most functions never actually used the original
form of __mingw_ovr at all?

// Martin


Martin Storsjö (5):
  crt: Use the right options in the UCRT non-inline _snwprintf
  headers: Remove UCRT inline fwprintf and _snwprintf
  headers: Don't redefine the __mingw_ovr define in swprintf.inl and
    wchar.h
  headers: Use __mingw_ovr instead of explicitly static inline
  headers: Stop using the __mingw_static_ovr macro

 mingw-w64-crt/stdio/ucrt__snwprintf.c |  2 +-
 mingw-w64-headers/crt/_mingw_mac.h    |  4 ---
 mingw-w64-headers/crt/stdio.h         | 30 ++++-------------
 mingw-w64-headers/crt/swprintf.inl    | 13 --------
 mingw-w64-headers/crt/time.h          | 48 +++++++++++++--------------
 mingw-w64-headers/crt/wchar.h         | 37 ++-------------------
 6 files changed, 34 insertions(+), 100 deletions(-)

-- 
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