Skip to content

Commit

Permalink
Remove annoying GCC warning when compiling on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
digit-google committed Oct 6, 2023
1 parent 93d0d35 commit f6e83fa
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/disk_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,15 @@ RealDiskInterface::RealDiskInterface()
HINSTANCE ntdll_lib = ::GetModuleHandleW(L"ntdll");
if (ntdll_lib) {
typedef BOOLEAN(WINAPI FunctionType)();
auto* func_ptr = reinterpret_cast<FunctionType*>(
::GetProcAddress(ntdll_lib, "RtlAreLongPathsEnabled"));
// An intermediate cast to void* is needed to avoid a strange
// GCC warning that looks like:
//
// warning: cast between incompatible function types from \
// 'FARPROC' {aka 'long long int (*)()'} to 'BOOLEAN (*)()' \
// {aka 'unsigned char (*)()'} [-Wcast-function-type]
//
auto* func_ptr = reinterpret_cast<FunctionType*>(reinterpret_cast<void*>(
::GetProcAddress(ntdll_lib, "RtlAreLongPathsEnabled")));
if (func_ptr) {
long_paths_enabled_ = (*func_ptr)();
}
Expand Down

0 comments on commit f6e83fa

Please sign in to comment.