我正在使用 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
在标题中,所以我不知道为什么给我这个错误。另外,这里是 a link to strsafe.h if you want to look at the header yourself .编辑:
我在网上找到了以下片段(如果有人可以提供更多信息,请告诉我,评论中想说什么?):
// 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
最佳答案
该评论表明应该有一个 strsafe 库,但它不存在。 __CRT__NO_INLINE
定义必须暗示某处有一个编译库来提供函数,而不是使用头文件中的内联函数。
因此,如果该库不存在(但它似乎认为应该存在),则允许使用内联函数。
但是,这是为了修复链接错误。编译代码时是否遇到链接错误?或者你只是得到警告?如果您只收到警告,则表示您确实拥有 strsafe 库。完全有可能没有办法消除该消息并仍然使用该函数的编译版本。
关于g++ - 如何摆脱g++中的 "inline function used but never defined"警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8513230/