locale: Fix compilation error in C++ mode on MSVC.
authorBruno Haible <bruno@clisp.org>
Wed, 11 Dec 2019 09:05:27 +0000 (10:05 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 11 Dec 2019 10:38:52 +0000 (11:38 +0100)
* m4/locale_h.m4 (gl_LOCALE_H): Don't set REPLACE_STRUCT_LCONV on MSVC.
* lib/locale.in.h (int_p_cs_precedes, int_p_sign_posn,
int_p_sep_by_space, int_n_cs_precedes, int_n_sign_posn,
int_n_sep_by_space): Define as macros on MSVC.

ChangeLog
lib/locale.in.h
m4/locale_h.m4

index 0b00316dca0f3d7ee17ed4571fe31e0a7868cea8..ef6280b014267793b317c87f5ef622344ca0fd30 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2019-12-11  Bruno Haible  <bruno@clisp.org>
+
+       locale: Fix compilation error in C++ mode on MSVC.
+       * m4/locale_h.m4 (gl_LOCALE_H): Don't set REPLACE_STRUCT_LCONV on MSVC.
+       * lib/locale.in.h (int_p_cs_precedes, int_p_sign_posn,
+       int_p_sep_by_space, int_n_cs_precedes, int_n_sign_posn,
+       int_n_sep_by_space): Define as macros on MSVC.
+
 2019-12-11  Bruno Haible  <bruno@clisp.org>
 
        wchar: Fix compilation error in C++ mode on MSVC.
index 918d4dd2bd4789c82c7dc59ac95fe8d5b61edad6..77b8b3ba91465a24a65f4e76850f7f24bc99355b 100644 (file)
 # define LC_MESSAGES 1729
 #endif
 
+/* On native Windows with MSVC, 'struct lconv' lacks the members int_p_* and
+   int_n_*.  Instead of overriding 'struct lconv', merely define these member
+   names as macros.  This avoids trouble in C++ mode.  */
+#if defined _MSC_VER
+# define int_p_cs_precedes   p_cs_precedes
+# define int_p_sign_posn     p_sign_posn
+# define int_p_sep_by_space  p_sep_by_space
+# define int_n_cs_precedes   n_cs_precedes
+# define int_n_sign_posn     n_sign_posn
+# define int_n_sep_by_space  n_sep_by_space
+#endif
+
 /* Bionic libc's 'struct lconv' is just a dummy.  */
 #if @REPLACE_STRUCT_LCONV@
 # define lconv rpl_lconv
index 380e40b00e3ba7393f6b6872efa577f71d3d56a6..c0ec3fc808eb4b817c978bb9c65571ea04d5ba69 100644 (file)
@@ -1,4 +1,4 @@
-# locale_h.m4 serial 22
+# locale_h.m4 serial 23
 dnl Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -56,7 +56,20 @@ AC_DEFUN([gl_LOCALE_H],
        [gl_cv_sys_struct_lconv_ok=no])
     ])
   if test $gl_cv_sys_struct_lconv_ok = no; then
-    REPLACE_STRUCT_LCONV=1
+    dnl On native Windows with MSVC, merely define these member names as macros.
+    dnl This avoids trouble in C++ mode.
+    case "$host_os" in
+      mingw*)
+        AC_EGREP_CPP([Special], [
+#ifdef _MSC_VER
+ Special
+#endif
+          ],
+          [],
+          [REPLACE_STRUCT_LCONV=1])
+        ;;
+      *) REPLACE_STRUCT_LCONV=1 ;;
+    esac
   fi
 
   dnl <locale.h> is always overridden, because of GNULIB_POSIXCHECK.