On 2017/4/3 11:23, David Grayson wrote:
Oops, I did a bad job of testing LH_Mouse's patch because I was trying to
judge whether a broken build of a program got worse.  It turns out his
patch made the build worse, causing undefined reference errors for
functions like StringCbLengthA that get defined in strsafe.h when compiled
as a part of a library.  It seems like GCC won't emit a symbol for a
function if you declared it as inline (which is not surprising).  This is
probably because of the issue I pointed out in the second paragraph of my
last email.

On Sun, Apr 2, 2017 at 8:12 PM, David Grayson <[email protected]>
wrote:

However, that patch seems like it could be wrong too, since when strsafe.h
is used to compile the library, all the library functions will have
__inline in their declarations even though we are compiling them with the
intent to make normal non-inline functions in a static library.


The macro `__STRSAFE__NO_INLINE` was introduced in commit `3a48e8af10d9eae4d434847f51598c664e7b2959`. From the commit message I guess `__CRT_STRSAFE_IMPL` is defined while building `libmingwex` so they must be defined as not inline there (see the file 'mingw-w64-crt/misc/strsafe.c').

Consequently there are three cases:

1. Neither is defined. This is the case for our users. All functions are declared as inline and inline definitions are provided. So it is OK.

2. `__STRSAFE__NO_INLINE` is defined while `__CRT_STRSAFE_IMPL` is not. This is the case for your problem. All functions are declared inline but inline definitions are not provided, resulting in warnings about 'inline functions declared but never defined'.

3. `__CRT_STRSAFE_IMPL` is defined. Inline definitions are provided for calls to external functions. The functions must not be declared as inline in this case. That is why my previous patch failed. Apologies for that.

New patch attached.


--
Best regards,
LH_Mouse



From f1c12fd9f35525ca3569c3427f953afb10b47588 Mon Sep 17 00:00:00 2001
From: Liu Hao <[email protected]>
Date: Mon, 3 Apr 2017 02:00:15 +0800
Subject: [PATCH] include/strsafe.h: Fix warning 'inline function declared but
 never defined'.

Reference: https://sourceforge.net/p/mingw-w64/mailman/message/35763431/
Signed-off-by: Liu Hao <[email protected]>
---
 mingw-w64-headers/include/strsafe.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mingw-w64-headers/include/strsafe.h b/mingw-w64-headers/include/strsafe.h
index 36c7796c..74f924ab 100644
--- a/mingw-w64-headers/include/strsafe.h
+++ b/mingw-w64-headers/include/strsafe.h
@@ -81,7 +81,7 @@ typedef __LONG32 HRESULT;
 #endif
 #endif

-#ifndef __CRT_STRSAFE_IMPL
+#if !defined(__CRT__NO_INLINE) && !defined(__CRT_STRSAFE_IMPL)
 #define STRSAFEAPI _STRSAFE_EXTERN_C __inline HRESULT WINAPI
 /* Variadic functions can't be __stdcall.  */
 #define STRSAFEAPIV _STRSAFE_EXTERN_C __inline HRESULT
@@ -91,7 +91,7 @@ typedef __LONG32 HRESULT;
 #define STRSAFEAPIV HRESULT
 #endif

-#ifndef __CRT_STRSAFE_IMPL
+#if !defined(__CRT__NO_INLINE) && !defined(__CRT_STRSAFE_IMPL)
 #define STRSAFE_INLINE_API _STRSAFE_EXTERN_C __CRT_INLINE HRESULT WINAPI
 #else
 #define STRSAFE_INLINE_API HRESULT WINAPI
--
2.12.1


From f1c12fd9f35525ca3569c3427f953afb10b47588 Mon Sep 17 00:00:00 2001
From: Liu Hao <[email protected]>
Date: Mon, 3 Apr 2017 02:00:15 +0800
Subject: [PATCH] include/strsafe.h: Fix warning 'inline function declared but
 never defined'.

Reference: https://sourceforge.net/p/mingw-w64/mailman/message/35763431/
Signed-off-by: Liu Hao <[email protected]>
---
 mingw-w64-headers/include/strsafe.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mingw-w64-headers/include/strsafe.h 
b/mingw-w64-headers/include/strsafe.h
index 36c7796c..74f924ab 100644
--- a/mingw-w64-headers/include/strsafe.h
+++ b/mingw-w64-headers/include/strsafe.h
@@ -81,7 +81,7 @@ typedef __LONG32 HRESULT;
 #endif
 #endif
 
-#ifndef __CRT_STRSAFE_IMPL
+#if !defined(__CRT__NO_INLINE) && !defined(__CRT_STRSAFE_IMPL)
 #define STRSAFEAPI _STRSAFE_EXTERN_C __inline HRESULT WINAPI
 /* Variadic functions can't be __stdcall.  */
 #define STRSAFEAPIV _STRSAFE_EXTERN_C __inline HRESULT
@@ -91,7 +91,7 @@ typedef __LONG32 HRESULT;
 #define STRSAFEAPIV HRESULT
 #endif
 
-#ifndef __CRT_STRSAFE_IMPL
+#if !defined(__CRT__NO_INLINE) && !defined(__CRT_STRSAFE_IMPL)
 #define STRSAFE_INLINE_API _STRSAFE_EXTERN_C __CRT_INLINE HRESULT WINAPI
 #else
 #define STRSAFE_INLINE_API HRESULT WINAPI
-- 
2.12.1

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to