使用GoogleMock和mingw64编译测试应用程序。即使我链接到comctl32,我也会得到这个错误::
In function `DSA_Sort(_DSA*, int (*)(void const*, void const*, long long), long long)':
C:/msys64/mingw64/x86_64-w64-mingw32/include/commctrl.h:5350: undefined reference to `__imp_DSA_Sort'如果不链接到comctl32,额外的__imp_DSA_XXX()就是未定义的,比如__imp_DSA_DestroyCallback()。objdump libcomctl32.a -t不显示DSA_Sort(),但显示DSA_DestroyCallback。
V6.0.0源comctl32.def不显示DSA_Sort()。它在commctrl.def和coredll.def中,当然还有commctrl.h。
libcomctl32.a中丢失的DSA_sort()是mingw-w64的错误还是其他libxxx.a文件中的此函数?哪个?如果它是一个bug,应该如何报告它?
发布于 2019-01-14 19:09:07
Comctl32.dll
ld \Windows\System32\comctl32.dll --output-def=comctl32.def没有显示DSA_Sort(),尽管文档中说它应该在那里。
DSA_Sort
https://docs.microsoft.com/en-us/windows/desktop/api/dpa_dsa/nf-dpa_dsa-dsa_sort
Lib: ComCtl32.dll
BOOL DSA_Sort(
HDSA pdsa,
PFNDACOMPARE pfnCompare,
LPARAM lParam
);dsa_dsa.h
\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\dpa_dsa.h定义DSA_Sort()的方式与MinGW commctrl.h相同。
但如果定义了ISOLATION_AWARE_ENABLED,则dpa_dsa.h具有#include "dpa_dsa.inl",但MinGW不支持(https://sourceforge.net/p/mingw-w64/feature-requests/44/)。
\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\dpa_dsa.inl包含:
#define DSA_Sort IsolationAwareDSA_Sort并有这样的内联实现:
ISOLATION_AWARE_INLINE BOOL IsolationAwarePrivatenCv IsolationAwareDSA_Sort(_Inout_ HDSA pdsa,_In_ PFNDACOMPARE pfnCompare,_In_ LPARAM lParam)
{
BOOL fResult = FALSE;
typedef BOOL (WINAPI* PFN)(_Inout_ HDSA pdsa,_In_ PFNDACOMPARE pfnCompare,_In_ LPARAM lParam);
static PFN s_pfn;
PFN __IsolationAware_pfn = s_pfn;
ULONG_PTR ulpCookie = 0;
const BOOL fActivateActCtxSuccess =
IsolationAwarePrivateT_SAbnPgpgk ||
IsolationAwarePrivateT_SqbjaYRiRY ||
IsolationAwarePrivatenPgViNgRzlnPgpgk(&ulpCookie);
if (!fActivateActCtxSuccess)
return fResult;
__try
{
if (__IsolationAware_pfn == NULL)
{
__IsolationAware_pfn = (PFN) Dpa_dsaIsolationAwarePrivatetRgCebPnQQeRff_pbZPgYQP_QYY("DSA_Sort");
if (__IsolationAware_pfn == NULL)
__leave;
s_pfn = __IsolationAware_pfn;
}
fResult = __IsolationAware_pfn(pdsa,pfnCompare,lParam);
}
__finally
{
if (!IsolationAwarePrivateT_SAbnPgpgk
|| !IsolationAwarePrivateT_SqbjaYRiRY
)
{
const BOOL fPreserveLastError = (fResult == FALSE);
const DWORD dwLastError = fPreserveLastError ? GetLastError() : NO_ERROR;
(void)IsolationAwareDeactivateActCtx(0, ulpCookie);
if (fPreserveLastError)
SetLastError(dwLastError);
}
}
return fResult;
}使用
#if !ISOLATION_AWARE_USE_STATIC_LIBRARY
FARPROC IsolationAwarePrivatenCv Dpa_dsaIsolationAwarePrivatetRgCebPnQQeRff_pbZPgYQP_QYY(LPCSTR pszProcName);
#endif /* ISOLATION_AWARE_USE_STATIC_LIBRARY */似乎Windows API显式地对MinGW隐藏了这个函数。
另请参阅:https://www.geoffchappell.com/studies/windows/shell/comctl32/api/da/dsa/index.htm
https://stackoverflow.com/questions/54114864
复制相似问题