aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorJia Tan <jiat0218@gmail.com>2023-01-19 20:35:09 +0800
committerJia Tan <jiat0218@gmail.com>2023-01-19 20:35:09 +0800
commitb43ff180fb2e372adce876bfa155fc9bcf0c3db4 (patch)
tree9cb6801d2cc29b3acb20db210679ad71cac2290f /src/common
parenttuklib_common: Define __has_warning if it is not defined. (diff)
downloadxz-b43ff180fb2e372adce876bfa155fc9bcf0c3db4.tar.xz
tuklib_physmem: Silence warning from -Wcast-function-type on MinGW-w64.
tuklib_physmem depends on GetProcAddress() for both MSVC and MinGW-w64 to retrieve a function address. The proper way to do this is to cast the return value to the type of function pointer retrieved. Unfortunately, this causes a cast-function-type warning, so the best solution is to simply ignore the warning.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/tuklib_physmem.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common/tuklib_physmem.c b/src/common/tuklib_physmem.c
index a1bccb2f..73d37c29 100644
--- a/src/common/tuklib_physmem.c
+++ b/src/common/tuklib_physmem.c
@@ -87,8 +87,17 @@ tuklib_physmem(void)
HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
if (kernel32 != NULL) {
typedef BOOL (WINAPI *gmse_type)(LPMEMORYSTATUSEX);
+#if TUKLIB_GNUC_REQ(8,1) || (defined(__clang__) \
+ && __has_warning("-Wcast-function-type"))
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wcast-function-type"
+#endif
gmse_type gmse = (gmse_type)GetProcAddress(
kernel32, "GlobalMemoryStatusEx");
+#if TUKLIB_GNUC_REQ(8,1) || (defined(__clang__) \
+ && __has_warning("-Wcast-function-type"))
+# pragma GCC diagnostic pop
+#endif
if (gmse != NULL) {
MEMORYSTATUSEX meminfo;
meminfo.dwLength = sizeof(meminfo);