Skip to content

cast between incompatible function types #474

@Xeverous

Description

@Xeverous

I get this on Windows while building the bootstrap project using MinGW-w64 with GCC 10.2.1

C:\mingw64\mingw64\bin\g++.exe -DFlextGL_EXPORTS -DMagnumGLObjects_EXPORTS -DNOMINMAX -DUNICODE -DWIN32_LEAN_AND_MEAN -D_UNICODE @CMakeFiles/MagnumGLObjects.dir/includes_CXX.rsp -O3 -DNDEBUG -std=c++11 -Wall -Wextra -Wold-style-cast -Winit-self -Werror=return-type -Wmissing-declarations -Wpedantic -fvisibility=hidden -fvisibility-inlines-hidden -Wzero-as-null-pointer-constant -Wdouble-promotion -fno-strict-aliasing -o CMakeFiles\MagnumGLObjects.dir\DebugOutput.cpp.obj -c [...]external\magnum\src\Magnum\GL\DebugOutput.cpp
[...]external\magnum\src\Magnum\Platform\Implementation\DpiScaling.cpp: In function 'bool Magnum::Platform::Implementation::isWindowsAppDpiAware()':
[...]external\magnum\src\Magnum\Platform\Implementation\DpiScaling.cpp:158:46: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'HRESULT (*)(HANDLE, PROCESS_DPI_AWARENESS*)' {aka 'long int (*)(void*, PROCESS_DPI_AWARENESS*)'} [-Wcast-function-type]
  158 |         auto* const getProcessDpiAwareness = reinterpret_cast<HRESULT(WINAPI *)(HANDLE, PROCESS_DPI_AWARENESS*)>(GetProcAddress(shcore, "GetProcessDpiAwareness"));
      |                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[...]external\magnum\src\Magnum\Platform\Implementation\DpiScaling.cpp:169:36: warning: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'BOOL (*)()' {aka 'int (*)()'} [-Wcast-function-type]
  169 |     auto const isProcessDPIAware = reinterpret_cast<BOOL(WINAPI *)()>(GetProcAddress(user32, "IsProcessDPIAware"));
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Second thing, I'm worried about the -fno-strict-aliasing. It basically means the code has undefined behavior in proper standard mode - does it come from some dependecy or is it magnum's addition?

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions