Question

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
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top