我正在使用mingw-w64。 我包含了strsafe.h
,并得到以下警告:
warning: inline function 'HRESULT StringCchPrintfA(STRSAFE_LPSTR, size_t, STRS
AFE_LPCSTR, ...)' used but never defined [enabled by default]
我使用的唯一标志是
-Wall -DDEBUG -g
。我知道你必须在同一个头文件中定义内联函数,我查看了strsafe.h
,并且清楚地看到头文件中的StringCchPrintfA
,所以我不知道为什么会出现这个错误。此外,这里有一个链接到strsafe.h的链接,如果您想自己查看头文件。
编辑:
我在网上找到了以下代码片段(如果有人可以提供更多信息,请告诉我,在评论中他们想说什么?):// Work around lack of strsafe library in mingw-w64, do let their
// strsafe.h provide inlines of StringCchVPrintfA etc, avoid linking
// errors in a debug build.
#ifdef __CRT__NO_INLINE
#undef __CRT__NO_INLINE
#define DID_UNDEFINE__CRT__NO_INLINE
#endif
extern "C" {
#endif
#include <strsafe.h>
#ifdef __MINGW32__
}
#ifdef DID_UNDEFINE__CRT__NO_INLINE
#define __CRT__NO_INLINE
#endif
#endif
StringCchPrintfA
就不会是内联函数。 - Jesse Good#define STRSAFEAPI static __inline HRESULT WINAPI
,因此该函数是static __inline
,无论__CRT__NO_INLINE的状态如何。 - tpg2114strsafe.h
之前添加#undef__CRT__NO_INLINE
,警告消失了,所以我必须找到它被定义的地方。 - Jesse Good