Object files in archive libcrtdll_extra.a (which are linked into import
library for crtdll.dll) cannot use msvcrt.h as it uses msvcrt.dll runtime
library.
So avoid using msvcrt.h and __mingw_get_msvcrt_handle() in crtdll.dll
runtime and directly use "setlocale_codepage_hack" implementation.
This fixes building of lc_locale_func.c for libcrtdll_extra.a archive.
---
mingw-w64-crt/misc/lc_locale_func.c | 31 +++++++++++++++++++----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/mingw-w64-crt/misc/lc_locale_func.c
b/mingw-w64-crt/misc/lc_locale_func.c
index e6847ae8b663..8f9ccd4b14e1 100644
--- a/mingw-w64-crt/misc/lc_locale_func.c
+++ b/mingw-w64-crt/misc/lc_locale_func.c
@@ -2,18 +2,11 @@
#define ___lc_codepage_func __dummy____lc_codepage_func
#include <windows.h>
#include <locale.h>
-#include <msvcrt.h>
#undef __lc_codepage
#undef ___lc_codepage_func
#include "mb_wc_common.h"
-static unsigned int *msvcrt__lc_codepage;
-static unsigned int __cdecl msvcrt___lc_codepage_func(void)
-{
- return *msvcrt__lc_codepage;
-}
-
static unsigned int __cdecl setlocale_codepage_hack(void)
{
/* locale :: "lang[_country[.code_page]]" | ".code_page" */
@@ -21,14 +14,23 @@ static unsigned int __cdecl setlocale_codepage_hack(void)
return cp_str ? atoi(cp_str + 1) : 0;
}
-static unsigned int __cdecl init_codepage_func(void);
-unsigned int (__cdecl *__MINGW_IMP_SYMBOL(___lc_codepage_func))(void) =
init_codepage_func;
+#ifndef __LIBMSVCRT_OS__
-unsigned int __cdecl ___lc_codepage_func (void)
+unsigned int (__cdecl *__MINGW_IMP_SYMBOL(___lc_codepage_func))(void) =
setlocale_codepage_hack;
+
+#else
+
+#include <msvcrt.h>
+
+static unsigned int *msvcrt__lc_codepage;
+static unsigned int __cdecl msvcrt___lc_codepage_func(void)
{
- return __MINGW_IMP_SYMBOL(___lc_codepage_func) ();
+ return *msvcrt__lc_codepage;
}
+static unsigned int __cdecl init_codepage_func(void);
+unsigned int (__cdecl *__MINGW_IMP_SYMBOL(___lc_codepage_func))(void) =
init_codepage_func;
+
static unsigned int __cdecl init_codepage_func(void)
{
HMODULE msvcrt = __mingw_get_msvcrt_handle();
@@ -48,3 +50,10 @@ static unsigned int __cdecl init_codepage_func(void)
return (__MINGW_IMP_SYMBOL(___lc_codepage_func) = func)();
}
+
+#endif
+
+unsigned int __cdecl ___lc_codepage_func(void)
+{
+ return __MINGW_IMP_SYMBOL(___lc_codepage_func)();
+}
--
2.20.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public