From c2c7d5e91656e56168bbc258b7ab58180165b174 Mon Sep 17 00:00:00 2001 From: Mr-Leshiy Date: Mon, 26 Apr 2021 10:12:33 -0700 Subject: [PATCH] Fix cast-function-type warning (#8230) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Fixing cast-function-type which is appears during the following build: ```bash cmake .. -DFAIL_ON_WARNINGS=ON -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DCMAKE_SYSTEM_NAME=Windows make rocksdb ``` Here is the log: ``` /home/leshiy/Work/rocksdb/port/win/env_win.cc: In constructor ‘rocksdb::port::WinClock::WinClock()’: /home/leshiy/Work/rocksdb/port/win/env_win.cc:92:9: error: cast between incompatible function types from ‘FARPROC’ {aka ‘long long int (*)()’} to ‘rocksdb::port::WinClock::FnGetSystemTimePreciseAsFileTime’ {aka ‘void (*)(_FILETIME*)’} [-Werror=cast-function-type] 92 | (FnGetSystemTimePreciseAsFileTime)GetProcAddress( | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 93 | module, "GetSystemTimePreciseAsFileTime"); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors make[2]: *** [CMakeFiles/rocksdb.dir/build.make:4337: CMakeFiles/rocksdb.dir/port/win/env_win.cc.obj] Error 1 make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/rocksdb.dir/all] Error 2 make: *** [Makefile:91: all] Error 2 ``` Pull Request resolved: https://github.com/facebook/rocksdb/pull/8230 Reviewed By: jay-zhuang Differential Revision: D28000215 Pulled By: mrambacher fbshipit-source-id: 874782cf48f70470e3fbd9097585bf42e810ca61 --- port/win/env_win.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/port/win/env_win.cc b/port/win/env_win.cc index 01766c4d2..cc337c1f8 100644 --- a/port/win/env_win.cc +++ b/port/win/env_win.cc @@ -9,8 +9,6 @@ #if defined(OS_WIN) -#include "port/win/env_win.h" - #include // _rmdir, _mkdir, _getcwd #include #include // _access @@ -29,6 +27,7 @@ #include "monitoring/thread_status_util.h" #include "port/port.h" #include "port/port_dirent.h" +#include "port/win/env_win.h" #include "port/win/io_win.h" #include "port/win/win_logger.h" #include "port/win/win_thread.h" @@ -89,9 +88,8 @@ WinClock::WinClock() HMODULE module = GetModuleHandle("kernel32.dll"); if (module != NULL) { - GetSystemTimePreciseAsFileTime_ = - (FnGetSystemTimePreciseAsFileTime)GetProcAddress( - module, "GetSystemTimePreciseAsFileTime"); + GetSystemTimePreciseAsFileTime_ = (FnGetSystemTimePreciseAsFileTime)( + void*)GetProcAddress(module, "GetSystemTimePreciseAsFileTime"); } }