From 53abfac6acd04dff80ec6c8cfb0dd53f2f74dadb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Mon, 18 Jul 2022 03:25:00 +0200 Subject: Improve Library::GetProcAddress. It isn't really more safe, but it removes the need for a confusing function pointer cast, which is easy to get wrong. As far as the compiler is concerned, the result is literally the same, but it does force the caller to (indirectly, via the template parameter) cast the return value, which may be a good thing. --- c/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'c/main.cpp') diff --git a/c/main.cpp b/c/main.cpp index 2e2fbbf..08e6b96 100644 --- a/c/main.cpp +++ b/c/main.cpp @@ -156,16 +156,16 @@ static LRESULT CALLBACK CBTProc(const int nCode, const WPARAM wParam, const LPAR /* Look up constants. */ if (auto opLib = try_make(TEXT("User32.dll"))) - if (auto GetDpiForWindow = (UINT (*)(HWND))opLib->GetProcAddress("GetDpiForWindow")) + if (auto GetDpiForWindow = opLib->GetProcAddress("GetDpiForWindow")) g_iDPI = GetDpiForWindow(g_hWnd); if (auto opLib = try_make(TEXT("uxtheme.dll"))) - if (opLib->GetProcAddress("SetWindowTheme")) + if (opLib->GetProcAddress("SetWindowTheme")) g_bThemes = 1; LOGFONT lf; if (auto opLib = try_make(TEXT("User32.dll"))) { - if (opLib->GetProcAddress("SystemParametersInfo" WA)) { + if (opLib->GetProcAddress("SystemParametersInfo" WA)) { NONCLIENTMETRICS m; m.cbSize = sizeof(NONCLIENTMETRICS); SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &m, 0); -- cgit v1.2.3