From cc6745d8accfa37b8ed48a4ea4220ae80fb7f3bd Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 11 Dec 2019 10:05:27 +0100 Subject: [PATCH] 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. --- ChangeLog | 8 ++++++++ lib/locale.in.h | 12 ++++++++++++ m4/locale_h.m4 | 17 +++++++++++++++-- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b00316dca..ef6280b014 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2019-12-11 Bruno Haible + + 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 wchar: Fix compilation error in C++ mode on MSVC. diff --git a/lib/locale.in.h b/lib/locale.in.h index 918d4dd2bd..77b8b3ba91 100644 --- a/lib/locale.in.h +++ b/lib/locale.in.h @@ -64,6 +64,18 @@ # 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 diff --git a/m4/locale_h.m4 b/m4/locale_h.m4 index 380e40b00e..c0ec3fc808 100644 --- a/m4/locale_h.m4 +++ b/m4/locale_h.m4 @@ -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 is always overridden, because of GNULIB_POSIXCHECK. -- 2.39.5