1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

SystemStats: Silence function-cast warnings

This commit is contained in:
reuk 2025-03-03 12:11:51 +00:00
parent f985cf0c31
commit 90695ce7b6
No known key found for this signature in database

View file

@ -247,21 +247,34 @@ static DebugFlagsInitialiser debugFlagsInitialiser;
RTL_OSVERSIONINFOW getWindowsVersionInfo(); RTL_OSVERSIONINFOW getWindowsVersionInfo();
RTL_OSVERSIONINFOW getWindowsVersionInfo() RTL_OSVERSIONINFOW getWindowsVersionInfo()
{ {
using RtlGetVersion = LONG (WINAPI*) (PRTL_OSVERSIONINFOW);
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wcast-function-type")
static const auto rtlGetVersion = std::invoke ([]() -> RtlGetVersion
{
if (auto* moduleHandle = ::GetModuleHandleW (L"ntdll.dll"))
if (auto* result = (RtlGetVersion) ::GetProcAddress (moduleHandle, "RtlGetVersion"))
return result;
// Unable to locate function! Please let the JUCE team know your current platform/environment
// so that we can fix this issue.
jassertfalse;
return {};
});
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
if (rtlGetVersion == nullptr)
return {};
RTL_OSVERSIONINFOW versionInfo = {}; RTL_OSVERSIONINFOW versionInfo = {};
if (auto* moduleHandle = ::GetModuleHandleW (L"ntdll.dll")) versionInfo.dwOSVersionInfoSize = sizeof (versionInfo);
{ LONG STATUS_SUCCESS = 0;
using RtlGetVersion = LONG (WINAPI*) (PRTL_OSVERSIONINFOW);
if (auto* rtlGetVersion = (RtlGetVersion) ::GetProcAddress (moduleHandle, "RtlGetVersion")) if (rtlGetVersion (&versionInfo) != STATUS_SUCCESS)
{ versionInfo = {};
versionInfo.dwOSVersionInfoSize = sizeof (versionInfo);
LONG STATUS_SUCCESS = 0;
if (rtlGetVersion (&versionInfo) != STATUS_SUCCESS)
versionInfo = {};
}
}
return versionInfo; return versionInfo;
} }
@ -332,18 +345,23 @@ bool SystemStats::isOperatingSystem64Bit()
#if JUCE_64BIT #if JUCE_64BIT
return true; return true;
#else #else
typedef BOOL (WINAPI* LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); using LPFN_ISWOW64PROCESS = BOOL (WINAPI*) (HANDLE, PBOOL);
const auto moduleHandle = GetModuleHandleA ("kernel32"); JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wcast-function-type")
if (moduleHandle == nullptr) static const auto fnIsWow64Process = std::invoke ([]() -> LPFN_ISWOW64PROCESS
{ {
jassertfalse; if (auto* moduleHandle = ::GetModuleHandleA ("kernel32"))
return false; if (auto* result = (LPFN_ISWOW64PROCESS) ::GetProcAddress (moduleHandle, "IsWow64Process"))
} return result;
LPFN_ISWOW64PROCESS fnIsWow64Process // Unable to locate function! Please let the JUCE team know your current platform/environment
= (LPFN_ISWOW64PROCESS) GetProcAddress (moduleHandle, "IsWow64Process"); // so that we can fix this issue.
jassertfalse;
return {};
});
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
BOOL isWow64 = FALSE; BOOL isWow64 = FALSE;