Skip to content

Windows GNU ABI / MINGW support #32

@mizvekov

Description

@mizvekov

WIndows GNU ABI has different mangling than MSVC ABI, so the linker symbol aliases for GetLastError / FormatMessage etc don't work.

These aliases instead would work:

#if defined(__MINGW32__)
#if defined(__x86_64__)
#pragma comment(linker, "/alternatename:_ZN13system_error25win3212GetLastErrorEv=GetLastError")
#pragma comment(linker, "/alternatename:_ZN13system_error25win3214FormatMessageWEmPKvmmPwmPv=FormatMessageW")
#pragma comment(linker, "/alternatename:_ZN13system_error25win3219WideCharToMultiByteEjmPKwiPciPKcPi=WideCharToMultiByte")
#elif defined(__i386__)
#pragma comment(linker, "/alternatename:__ZN13system_error25win3212GetLastErrorEv@0=__imp__GetLastError@0")
#pragma comment(linker, "/alternatename:__ZN13system_error25win3214FormatMessageWEmPKvmmPwmPv@28=__imp__FormatMessageW@28")
#pragma comment(linker, "/alternatename:__ZN13system_error25win3219WideCharToMultiByteEjmPKwiPciPKcPi@32=__imp__WideCharToMultiByte@32")
#else
#error Unknown architecture
#endif
#else
...
#endif

The above is enough to get it working with clang/lld targeting MINGW64 / GNU ABI (which is only what I need personally).
GCC / ld however do not support neither the #pragma comment nor /alternatename, so a different strategy is needed there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions