Fix link error due to StrCmpLogicalW() when using MSVC

Add the #pragma to link with shlwapi in the same object file which uses
this function, as even though the same pragma was already present in
other files, they could be completely discarded by the linker resulting
in link errors about unresolved StrCmpLogicalW() later.

Also move the MinGW-specific function declaration to the top of the
file, near the inclusion of the header which would normally declare it.
This commit is contained in:
Vadim Zeitlin
2020-12-08 16:43:33 +01:00
parent b2878e992c
commit 8bf8cf4aae

View File

@@ -27,8 +27,20 @@
#if defined( __WINDOWS__ )
#include <shlwapi.h>
#endif
// In some distributions of MinGW32, this function is exported in the library,
// but not declared in shlwapi.h. Therefore we declare it here.
#if defined( __MINGW32_TOOLCHAIN__ )
extern "C" __declspec(dllimport) int WINAPI StrCmpLogicalW(LPCWSTR psz1, LPCWSTR psz2);
#endif
// For MSVC we can also link the library containing StrCmpLogicalW()
// directly from here, for the other compilers this needs to be done at
// makefiles level.
#ifdef __VISUALC__
#pragma comment(lib, "shlwapi")
#endif
#endif
// ============================================================================
// ArrayString
@@ -892,17 +904,6 @@ int wxCMPFUNC_CONV wxCmpNaturalGeneric(const wxString& s1, const wxString& s2)
return comparison;
}
// ----------------------------------------------------------------------------
// Declaration of StrCmpLogicalW()
// ----------------------------------------------------------------------------
//
// In some distributions of MinGW32, this function is exported in the library,
// but not declared in shlwapi.h. Therefore we declare it here.
#if defined( __MINGW32_TOOLCHAIN__ )
extern "C" __declspec(dllimport) int WINAPI StrCmpLogicalW(LPCWSTR psz1, LPCWSTR psz2);
#endif
// ----------------------------------------------------------------------------
// wxCmpNatural
// ----------------------------------------------------------------------------