From: Michael An Date: Thu, 21 Jun 2018 01:05:27 +0000 (-0400) Subject: Fix GCC 8 cast warnings X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=06a853eb9c5173c30b31e75d0828c29dd65ebca4 Fix GCC 8 cast warnings Silences the following warnings when compiling with GCC 8. The fix is to use an intermediate pointer to anonymous function: ``` misc.cpp: In function 'int WinProcGroup::get_group(size_t)': misc.cpp:241:77: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'fun1_t' {aka 'bool (*)(_LOGICAL_PROCESSOR_RELATIONSHIP, _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*, long unsigned int*)'} [-Wcast-function-type] auto fun1 = (fun1_t)GetProcAddress(k32, "GetLogicalProcessorInformationEx"); ^ misc.cpp: In function 'void WinProcGroup::bindThisThread(size_t)': misc.cpp:309:71: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'fun2_t' {aka 'bool (*)(short unsigned int, _GROUP_AFFINITY*)'} [-Wcast-function-type] auto fun2 = (fun2_t)GetProcAddress(k32, "GetNumaNodeProcessorMaskEx"); ^ misc.cpp:310:67: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'fun3_t' {aka 'bool (*)(void*, const _GROUP_AFFINITY*, _GROUP_AFFINITY*)'} [-Wcast-function-type] auto fun3 = (fun3_t)GetProcAddress(k32, "SetThreadGroupAffinity"); ^ ``` No functional change. --- diff --git a/src/misc.cpp b/src/misc.cpp index 4e2d4057..e6a29af7 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -238,7 +238,7 @@ int get_group(size_t idx) { // Early exit if the needed API is not available at runtime HMODULE k32 = GetModuleHandle("Kernel32.dll"); - auto fun1 = (fun1_t)GetProcAddress(k32, "GetLogicalProcessorInformationEx"); + auto fun1 = (fun1_t)(void(*)())GetProcAddress(k32, "GetLogicalProcessorInformationEx"); if (!fun1) return -1; @@ -306,8 +306,8 @@ void bindThisThread(size_t idx) { // Early exit if the needed API are not available at runtime HMODULE k32 = GetModuleHandle("Kernel32.dll"); - auto fun2 = (fun2_t)GetProcAddress(k32, "GetNumaNodeProcessorMaskEx"); - auto fun3 = (fun3_t)GetProcAddress(k32, "SetThreadGroupAffinity"); + auto fun2 = (fun2_t)(void(*)())GetProcAddress(k32, "GetNumaNodeProcessorMaskEx"); + auto fun3 = (fun3_t)(void(*)())GetProcAddress(k32, "SetThreadGroupAffinity"); if (!fun2 || !fun3) return;