]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
gettext.m4: Recognize the shared GNU libintl on MSVC.
authorBruno Haible <bruno@clisp.org>
Sat, 7 Jun 2025 03:01:34 +0000 (05:01 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 7 Jun 2025 03:01:34 +0000 (05:01 +0200)
Reported by Kirill Makurin <maiddaisuki@outlook.com>
in <https://lists.gnu.org/archive/html/bug-m4/2025-06/msg00000.html>.

* gettext-runtime/m4/gettext.m4 (AM_GNU_GETTEXT): On MSVC, don't try to use
_nl_msg_cat_cntr.
* NEWS: Mention it.

NEWS
gettext-runtime/m4/gettext.m4

diff --git a/NEWS b/NEWS
index 4c93e9ea3f05d744834f8b54095c682a716a5b70..f364ebb3ed5e20c7a014add1b9e05d5138578010 100644 (file)
--- 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:
index 7de17f99c02c28a2950cc3dd1e565822f3b637a1..908f829c3fd6fd00939a49a627bd799ed61fd7dc 100644 (file)
@@ -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   <libintl.h>, 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 <libintl.h>
 #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 <libintl.h>
 #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 <libintl.h>
 #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"