How to get rid of “inline function used but never defined” warning in g++

一笑奈何 提交于 2019-12-14 01:11:54

问题


I'm using mingw-w64. I'm including strsafe.h and getting the following warning:

warning: inline function 'HRESULT StringCchPrintfA(STRSAFE_LPSTR, size_t, STRS
AFE_LPCSTR, ...)' used but never defined [enabled by default]

The only flags flags I used are -Wall -DDEBUG -g. I know that you have to define inline functions in the same header and I looked at strsafe.h and I clearly can see that StringCchPrintfA in the header, so I don't know why its giving me this error. Also, here is a link to strsafe.h if you want to look at the header yourself.

Edit:

I found the following snippet online (if anybody can provide more information please let me know, what are the trying to say in the comment?):

// 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

回答1:


The comment is indicating that there is supposed to be a strsafe library but it's not there. The __CRT__NO_INLINE definition must imply that there is a compiled library somewhere to provide the functions instead of using the inline'd ones from the header.

So, in the case where that library is not present (but it seems to think it should be), allow the inline functions to be used.

But, this is to fix linking errors. Do you get linking errors when you compile your code? Or do you just get the warning? If you only get the warning, it means you do in fact have the strsafe library. It's entirely plausible that there is no way to eliminate the message and still use the compiled version of the function.



来源:https://stackoverflow.com/questions/8513230/how-to-get-rid-of-inline-function-used-but-never-defined-warning-in-g

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!