mingw: fix calling convention for strftime()

`strftime` uses `__cdecl` and not `__stdcall`.  This was exposed by
refactoring in commit 26c9fbab46 (MINGW-w64: Fix string(TIMESTAMP) build
on 32bits, 2021-11-16, v3.22.0~1^2).

This fixes a crash creating a timestamp with clang+mingw-w64 targeting x86.

Fixes: #22939
This commit is contained in:
Christoph Reiter
2021-11-25 20:17:10 +01:00
committed by Brad King
parent 5109a22d61
commit 992e6d7c5d

View File

@@ -197,7 +197,7 @@ std::string cmTimestamp::AddTimestampComponent(char flag,
#ifdef __MINGW32__
/* See a bug in MinGW: https://sourceforge.net/p/mingw-w64/bugs/793/. A work
* around is to try to use strftime() from ucrtbase.dll. */
using T = size_t(WINAPI*)(char*, size_t, const char*, const struct tm*);
using T = size_t(__cdecl*)(char*, size_t, const char*, const struct tm*);
auto loadUcrtStrftime = []() -> T {
auto handle =
LoadLibraryExA("ucrtbase.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);