From: Bruno Haible Date: Sat, 7 Jun 2025 03:01:34 +0000 (+0200) Subject: gettext.m4: Recognize the shared GNU libintl on MSVC. X-Git-Tag: v0.26~112 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8000b5d9e31796eedae529b1477750dc16971ad5;p=thirdparty%2Fgettext.git gettext.m4: Recognize the shared GNU libintl on MSVC. Reported by Kirill Makurin in . * gettext-runtime/m4/gettext.m4 (AM_GNU_GETTEXT): On MSVC, don't try to use _nl_msg_cat_cntr. * NEWS: Mention it. --- diff --git a/NEWS b/NEWS index 4c93e9ea3..f364ebb3e 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,10 @@ Version 0.26 - July 2025 in a context that requires a format string. You can override this heuristic by using a comment of the form /* xgettext: c-format */. +# Bug fixes: + - The AM_GNU_GETTEXT macro now recognizes, on MSVC, the GNU libintl built + as a shared library. + Version 0.25 - May 2025 # Programming languages support: diff --git a/gettext-runtime/m4/gettext.m4 b/gettext-runtime/m4/gettext.m4 index 7de17f99c..908f829c3 100644 --- a/gettext-runtime/m4/gettext.m4 +++ b/gettext-runtime/m4/gettext.m4 @@ -1,5 +1,5 @@ # gettext.m4 -# serial 81 (gettext-0.24) +# serial 82 (gettext-0.26) dnl Copyright (C) 1995-2025 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -151,13 +151,37 @@ changequote([,])dnl gt_expression_test_code= fi + dnl In the test code below: + dnl * We test for the presence of _nl_msg_cat_cntr because GNU libc and + dnl libintl define this variable, whereas Solaris 10 libc/libintl + dnl (which we don't want to use, as it does not support GNU .mo files) + dnl does not define it. + dnl * We don't test for _nl_msg_cat_cntr on MSVC, because the use of a + dnl variable under MSVC depends on whether it is exported by a shared + dnl library or a static library: If libintl is a shared library, we + dnl would have to declare it with __declspec(dllimport), whereas if it + dnl is a static library, we would have to declare it without such a + dnl __declspec. But libintl comes with just one header file, + dnl , that does not declare _nl_msg_cat_cntr and that does + dnl not tell us whether the library was built shared or static. + dnl * We test for the presence of _nl_domain_bindings because GNU libc + dnl defines this variable, whereas NetBSD libc (which we don't want to + dnl use, as it was broken at least in 2002) does not define it. + dnl * We test for the presence of _nl_expand_alias because GNU libintl + dnl defines this function, whereas NetBSD libintl (which we don't want + dnl to use, as it was broken at least in 2002) does not define it. + AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc], [AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[ #include #ifndef __GNU_GETTEXT_SUPPORTED_REVISION +#if defined _MSC_VER +#define _nl_msg_cat_cntr 0 +#else extern int _nl_msg_cat_cntr; +#endif extern int *_nl_domain_bindings; #define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_domain_bindings) #else @@ -194,7 +218,11 @@ return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION [[ #include #ifndef __GNU_GETTEXT_SUPPORTED_REVISION +#if defined _MSC_VER +#define _nl_msg_cat_cntr 0 +#else extern int _nl_msg_cat_cntr; +#endif extern #ifdef __cplusplus "C" @@ -227,7 +255,11 @@ return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION [[ #include #ifndef __GNU_GETTEXT_SUPPORTED_REVISION +#if defined _MSC_VER +#define _nl_msg_cat_cntr 0 +#else extern int _nl_msg_cat_cntr; +#endif extern #ifdef __cplusplus "C"