Skip to content

Commit fa65e83

Browse files
committed
[libcxx] Add cast to avoid pointer casting warning on Windows
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 999d4f8, 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.)
1 parent 9f449c3 commit fa65e83

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libcxx/src/chrono.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ typedef void(WINAPI* GetSystemTimeAsFileTimePtr)(LPFILETIME);
7777
class GetSystemTimeInit {
7878
public:
7979
GetSystemTimeInit() {
80-
fp =
81-
(GetSystemTimeAsFileTimePtr)GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "GetSystemTimePreciseAsFileTime");
80+
fp = (GetSystemTimeAsFileTimePtr)(void*)GetProcAddress(
81+
GetModuleHandleW(L"kernel32.dll"), "GetSystemTimePreciseAsFileTime");
8282
if (fp == nullptr)
8383
fp = GetSystemTimeAsFileTime;
8484
}

0 commit comments

Comments
 (0)