rang icon indicating copy to clipboard operation
rang copied to clipboard

A warning may be fixed

Open SodiumCyanide opened this issue 6 years ago • 3 comments

When I used parameter -Wextra in g++, it gives a warning:

[Warning] cast between incompatible function types from 'FARPROC' {aka 'long long int ()()'} to 'WINBOOL ()(HANDLE, FILE_INFO_BY_HANDLE_CLASS, LPVOID, DWORD)' {aka 'int ()(void, _FILE_INFO_BY_HANDLE_CLASS, void*, long unsigned int)'} [-Wcast-function-type]

It's on line 175 in rang.hpp:

inline bool isMsysPty(int fd) noexcept
    {
        // Dynamic load for binary compability with old Windows
        const auto ptrGetFileInformationByHandleEx
          = reinterpret_cast<decltype(&GetFileInformationByHandleEx)>(
            GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")),
                           "GetFileInformationByHandleEx"));
        if (!ptrGetFileInformationByHandleEx) {
            return false;
        }

All the parameters I used under Windows 10 1903, g++ 8.1.0: g++ -std=c++2a -Wall -Wextra -Dlocal

SodiumCyanide avatar Jul 21 '19 11:07 SodiumCyanide

I think its supposed to give a warning here but if you know a better solution I'd be glad to merge it.

agauniyal avatar Jul 27 '19 13:07 agauniyal

Well... Actually I have no idea about how to fix it. It seems that it's a previous problem in Windows API. I should ignore tons of warnings from MSVC library. :)

SodiumCyanide avatar Jul 31 '19 03:07 SodiumCyanide

@agauniyal I pulled a request for the fixed version of this warning.

SodiumCyanide avatar Mar 30 '20 02:03 SodiumCyanide