aboutsummaryrefslogtreecommitdiff
path: root/libcxx/src
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2024-05-20 23:30:51 +0300
committerGitHub <noreply@github.com>2024-05-20 23:30:51 +0300
commit250c39cd7aae8d4a6a76e2f04cfe5ce657f8260c (patch)
treeffce90b70c9bd6d41b696be69ce8b206f7eb4c9e /libcxx/src
parent223284316081e1af369c2d560da88e6211669250 (diff)
downloadllvm-250c39cd7aae8d4a6a76e2f04cfe5ce657f8260c.zip
llvm-250c39cd7aae8d4a6a76e2f04cfe5ce657f8260c.tar.gz
llvm-250c39cd7aae8d4a6a76e2f04cfe5ce657f8260c.tar.bz2
[libcxx] Add cast to avoid pointer casting warning on Windows (#92738)
This avoids the following build time warning, when building with the latest nightly Clang: warning: cast from 'FARPROC' (aka 'int (*)() __attribute__((stdcall))') to 'GetSystemTimeAsFileTimePtr' (aka 'void (*)(_FILETIME *) __attribute__((stdcall))') converts to incompatible function type [-Wcast-function-type-mismatch] This warning seems to have appeared since Clang commit 999d4f840777bf8de26d45947192aa0728edc0fb, which restructured. The GetProcAddress function returns a `FARPROC` type, which is `int (WINAPI *)()`. Directly casting this to another function pointer type triggers this warning, but casting to a `void*` inbetween avoids this issue. (On Unix-like platforms, dlsym returns a `void*`, which doesn't exhibit this casting problem.)
Diffstat (limited to 'libcxx/src')
-rw-r--r--libcxx/src/chrono.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/libcxx/src/chrono.cpp b/libcxx/src/chrono.cpp
index e7d6dfb..83e8a64 100644
--- a/libcxx/src/chrono.cpp
+++ b/libcxx/src/chrono.cpp
@@ -77,8 +77,8 @@ typedef void(WINAPI* GetSystemTimeAsFileTimePtr)(LPFILETIME);
class GetSystemTimeInit {
public:
GetSystemTimeInit() {
- fp =
- (GetSystemTimeAsFileTimePtr)GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "GetSystemTimePreciseAsFileTime");
+ fp = (GetSystemTimeAsFileTimePtr)(void*)GetProcAddress(
+ GetModuleHandleW(L"kernel32.dll"), "GetSystemTimePreciseAsFileTime");
if (fp == nullptr)
fp = GetSystemTimeAsFileTime;
}