bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

duplocale: Fix compilation error on Haiku


From: Bruno Haible
Subject: duplocale: Fix compilation error on Haiku
Date: Wed, 05 Apr 2023 02:36:31 +0200

On Haiku (2017), I'm seeing a compilation error in a testdir:

gcc-x86 -DHAVE_CONFIG_H -DEXEEXT=\"\" -DEXEEXT=\"\" -DNO_XMALLOC -DEXEEXT=\"\" 
-I. -I../../gllib -I..  -DGNULIB_STRICT_CHECKING=1 
-I/boot/home/config/non-packaged/include -Wall -fvisibility=hidden -g -O2 -MT 
copy-acl.o -MD -MP -MF $depbase.Tpo -c -o copy-acl.o ../../gllib/copy-acl.c &&\
mv -f $depbase.Tpo $depbase.Po
In file included from /boot/system/develop/headers/posix/sys/types.h:127:0,
                 from ./sys/types.h:39,
                 from ../../gllib/acl.h:23,
                 from ../../gllib/copy-acl.c:22:
./locale.h:761:1: error: unknown type name 'locale_t'
 _GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale) _GL_ARG_NONNULL 
((1)));
 ^
./locale.h:761:1: error: unknown type name 'locale_t'
 _GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale) _GL_ARG_NONNULL 
((1)));
 ^
Makefile:10864: recipe for target 'copy-acl.o' failed

configure has determined that 'duplocale' does not exist in libc,
and localename.m4 has then set
  gl_cv_onwards_func_duplocale='future OS version'
because when a platform does not have 'duplocale', future versions may get
'duplocale'. Thus config.status sets
  HAVE_DUPLOCALE = 0
  REPLACE_DUPLOCALE = 1
This situation is not a problem for so many other functions. But 'duplocale'
is different: When HAVE_DUPLOCALE is 0, it means that the type 'locale_t'
may not exist. And since Gnulib does not provide a substitute for 'locale_t'
we cannot define 'duplocale' nor 'rpl_duplocale'.

This patch fixes the compilation error.


2023-04-04  Bruno Haible  <bruno@clisp.org>

        duplocale: Fix compilation error on Haiku (regression 2023-01-22).
        * lib/locale.in.h (duplocale): If HAVE_DUPLOCALE = 0, don't declare it,
        even if REPLACE_DUPLOCALE = 1.
        * modules/duplocale (Depends-on, configure.ac): Don't compile a
        replacement if HAVE_DUPLOCALE = 0 and REPLACE_DUPLOCALE = 1.

diff --git a/lib/locale.in.h b/lib/locale.in.h
index e9c34182e5..e37702c4eb 100644
--- a/lib/locale.in.h
+++ b/lib/locale.in.h
@@ -245,23 +245,23 @@ _GL_WARN_ON_USE (newlocale, "newlocale is not portable");
 #endif
 
 #if @GNULIB_DUPLOCALE@ || (@GNULIB_LOCALENAME@ && 
@LOCALENAME_ENHANCE_LOCALE_FUNCS@ && @HAVE_DUPLOCALE@)
-# if @REPLACE_DUPLOCALE@
-#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#   undef duplocale
-#   define duplocale rpl_duplocale
-#   define GNULIB_defined_duplocale 1
-#  endif
+# if @HAVE_DUPLOCALE@ /* locale_t may be undefined if !@HAVE_DUPLOCALE@.  */
+#  if @REPLACE_DUPLOCALE@
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    undef duplocale
+#    define duplocale rpl_duplocale
+#    define GNULIB_defined_duplocale 1
+#   endif
 _GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale) _GL_ARG_NONNULL 
((1)));
 _GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale));
-# else
-#  if @HAVE_DUPLOCALE@
+#  else
 _GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale));
 #  endif
 # endif
 # if __GLIBC__ >= 2 && @HAVE_DUPLOCALE@
 _GL_CXXALIASWARN (duplocale);
 # endif
-# if @HAVE_DUPLOCALE@ || @REPLACE_DUPLOCALE@
+# if @HAVE_DUPLOCALE@
 #  ifndef HAVE_WORKING_DUPLOCALE
 #   define HAVE_WORKING_DUPLOCALE 1
 #  endif
diff --git a/modules/duplocale b/modules/duplocale
index 80d4aaaf54..7c1a8730a5 100644
--- a/modules/duplocale
+++ b/modules/duplocale
@@ -7,11 +7,12 @@ m4/duplocale.m4
 
 Depends-on:
 locale
-setlocale-null  [test $REPLACE_DUPLOCALE = 1]
+setlocale-null  [test $HAVE_DUPLOCALE = 1 && test $REPLACE_DUPLOCALE = 1]
 
 configure.ac:
 gl_FUNC_DUPLOCALE
-gl_CONDITIONAL([GL_COND_OBJ_DUPLOCALE], [test $REPLACE_DUPLOCALE = 1])
+gl_CONDITIONAL([GL_COND_OBJ_DUPLOCALE],
+               [test $HAVE_DUPLOCALE = 1 && test $REPLACE_DUPLOCALE = 1])
 AM_COND_IF([GL_COND_OBJ_DUPLOCALE], [
   gl_PREREQ_DUPLOCALE
 ])






reply via email to

[Prev in Thread] Current Thread [Next in Thread]