[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: printf, wchar
From: |
Bruno Haible |
Subject: |
Re: printf, wchar |
Date: |
Thu, 7 Jun 2007 15:38:54 +0200 |
User-agent: |
KMail/1.5.4 |
Simon Josefsson wrote:
> On uClinux I got:
>
> /bin/sh ../libtool --tag=CC --mode=compile ucfront-gcc m68k-elf-gcc -m5200
> -DCONFIG_COLDFIRE -DHAVE_CONFIG_H -I. -I.. -I../../../lib/gl -I../intl
> -I/data/fast/uclinux/uClinux-dist/lib/libgcrypt/inst/include
> -I/data/fast/uclinux/uClinux-dist/lib/libgpg-error/inst/include -g
> -fomit-frame-pointer -pipe -fno-common -fno-builtin -Wall -DEMBED -msep-data
> -Dlinux -D__linux__ -Dunix -D__uClinux__ -MT printf-parse.lo -MD -MP -MF
> .deps/printf-parse.Tpo -c -o printf-parse.lo ../../../lib/gl/printf-parse.c
> ucfront-gcc m68k-elf-gcc -m5200 -DCONFIG_COLDFIRE -DHAVE_CONFIG_H -I. -I..
> -I../../../lib/gl -I../intl
> -I/data/fast/uclinux/uClinux-dist/lib/libgcrypt/inst/include
> -I/data/fast/uclinux/uClinux-dist/lib/libgpg-error/inst/include -g
> -fomit-frame-pointer -pipe -fno-common -fno-builtin -Wall -DEMBED -msep-data
> -Dlinux -D__linux__ -Dunix -D__uClinux__ -MT printf-parse.lo -MD -MP -MF
> .deps/printf-parse.Tpo -c ../../../lib/gl/printf-parse.c -o printf-parse.o
> In file included from ./wchar.h:42,
> from ./stdint.h:94,
> from ../../../lib/gl/printf-parse.c:39:
> /data/fast/uclinux/uClinux-dist/uClibc/include/wchar.h:32:2: error: #error
> Attempted to include wchar.h when uClibc built without wide char support.
> make[7]: *** [printf-parse.lo] Error 1
>
> Configure says:
>
> checking wchar.h usability... no
> checking wchar.h presence... no
> checking for wchar.h... no
>
> The tests fail because:
>
> configure:24279: checking wchar.h usability
> configure:24296: ucfront-gcc m68k-elf-gcc -m5200 -DCONFIG_COLDFIRE -c -g
> -fomit-frame-pointer -pipe -fno-common -fno-builtin -Wall -DEMBED -msep-data
> -Dlinux -D__linux__ -Dunix -D__uClinux__ conftest.c >&5
> In file included from conftest.c:82:
> /data/fast/uclinux/uClinux-dist/uClibc/include/wchar.h:32:2: error: #error
> Attempted to include wchar.h when uClibc built without wide char support.
> configure:24302: $? = 1
OK, so the assumption that we made in January, that <wchar.h> is universally
present, is not valid.
> 2007-06-07 Simon Josefsson <address@hidden>
>
> * lib/wchar_.h: Don't include wchar.h if missing.
>
> --- wchar_.h 30 May 2007 15:01:38 +0200 1.5
> +++ wchar_.h 07 Jun 2007 11:31:38 +0200
> @@ -35,6 +35,7 @@
> #include <stdio.h>
> #include <time.h>
>
> +#if HAVE_WCHAR_H
> /* Include the original <wchar.h>. */
> /* The include_next requires a split double-inclusion guard. */
> #if @HAVE_INCLUDE_NEXT@
> @@ -42,6 +43,7 @@
> #else
> # include @ABSOLUTE_WCHAR_H@
> #endif
> +#endif
>
> #ifndef _GL_WCHAR_H
> #define _GL_WCHAR_H
There is a little more than this, because - as you know - we want the
replacement *.h files to be independent of <config.h> as far as possible.
I applied the appended patch.
> Alternatively, stdint_.h could avoid including wchar.h, but this fix
> seems cleaner because printf can always assume wchar.h, and the wchar
> module is responsible for making it appear as if the wchar.h intefaces
> works.
Yes, this is the purpose of the modules: that you don't need to change much
when we notice yet another portability problem. The 'wchar' module is a
dependency of the 'stdint' module, therefore lib/stdint_.h does not need to
be changed - it can assume a working <wchar.h> file.
But m4/stdint.m4 has to be changed, because it runs at a moment when the
replacement <wchar.h> is not yet in place.
Bruno
2007-06-07 Bruno Haible <address@hidden>
Work around the lack of <wchar.h> on some builds of uClibc.
* doc/headers/wchar.texi: Update.
* lib/wchar_.h: Include <wchar.h> only if it exists.
* m4/wchar.m4 (gl_WCHAR_H): Check for <wchar.h>. Set HAVE_WCHAR_H.
* m4/stdint.m4 (gl_STDINT_H): Check for <wchar.h>.
(gl_STDINT_TYPE_PROPERTIES): Don't try to include <wchar.h> if it
doesn't exist.
* modules/wchar (wchar.h): Substitute HAVE_WCHAR_H.
* modules/mbfile (Depends-on): Add wchar.
* modules/mbiter (Depends-on): Likewise.
* modules/mbuiter (Depends-on): Likewise.
*** lib/wchar_.h 30 May 2007 02:16:53 -0000 1.5
--- lib/wchar_.h 7 Jun 2007 13:25:51 -0000
***************
*** 35,46 ****
#include <stdio.h>
#include <time.h>
! /* Include the original <wchar.h>. */
/* The include_next requires a split double-inclusion guard. */
! #if @HAVE_INCLUDE_NEXT@
! # include_next <wchar.h>
! #else
! # include @ABSOLUTE_WCHAR_H@
#endif
#ifndef _GL_WCHAR_H
--- 35,49 ----
#include <stdio.h>
#include <time.h>
! /* Include the original <wchar.h> if it exists.
! Some builds of uClibc lack it. */
/* The include_next requires a split double-inclusion guard. */
! #if @HAVE_WCHAR_H@
! # if @HAVE_INCLUDE_NEXT@
! # include_next <wchar.h>
! # else
! # include @ABSOLUTE_WCHAR_H@
! # endif
#endif
#ifndef _GL_WCHAR_H
*** m4/stdint.m4 2 Jun 2007 20:45:23 -0000 1.31
--- m4/stdint.m4 7 Jun 2007 13:25:51 -0000
***************
*** 1,4 ****
! # stdint.m4 serial 25
dnl Copyright (C) 2001-2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
--- 1,4 ----
! # stdint.m4 serial 26
dnl Copyright (C) 2001-2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
***************
*** 222,227 ****
--- 222,231 ----
fi
AC_SUBST([HAVE_SYS_BITYPES_H])
+ dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
+ dnl character support).
+ AC_CHECK_HEADERS_ONCE([wchar.h])
+
gl_STDINT_TYPE_PROPERTIES
STDINT_H=stdint.h
fi
***************
*** 357,365 ****
included before <wchar.h>. */
#include <stddef.h>
#include <signal.h>
! #include <stdio.h>
! #include <time.h>
! #include <wchar.h>
]])
dnl gl_STDINT_TYPE_PROPERTIES
--- 361,371 ----
included before <wchar.h>. */
#include <stddef.h>
#include <signal.h>
! #if HAVE_WCHAR_H
! # include <stdio.h>
! # include <time.h>
! # include <wchar.h>
! #endif
]])
dnl gl_STDINT_TYPE_PROPERTIES
*** m4/wchar.m4 13 Jan 2007 05:23:37 -0000 1.1
--- m4/wchar.m4 7 Jun 2007 13:25:51 -0000
***************
*** 7,13 ****
dnl Written by Eric Blake.
! # wchar.m4 serial 1
AC_DEFUN([gl_WCHAR_H],
[
--- 7,13 ----
dnl Written by Eric Blake.
! # wchar.m4 serial 2
AC_DEFUN([gl_WCHAR_H],
[
***************
*** 20,25 ****
--- 20,34 ----
if test $gl_cv_header_wchar_h_standalone = yes; then
WCHAR_H=
else
+ dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
+ dnl character support).
+ AC_CHECK_HEADERS_ONCE([wchar.h])
+ if test $ac_cv_header_wchar_h = yes; then
+ HAVE_WCHAR_H=1
+ else
+ HAVE_WCHAR_H=0
+ fi
+ AC_SUBST([HAVE_WCHAR_H])
gl_ABSOLUTE_HEADER([wchar.h])
ABSOLUTE_WCHAR_H=\"$gl_cv_absolute_wchar_h\"
WCHAR_H=wchar.h
*** modules/mbfile 26 Sep 2005 13:58:51 -0000 1.2
--- modules/mbfile 7 Jun 2007 13:25:51 -0000
***************
*** 8,13 ****
--- 8,14 ----
Depends-on:
mbchar
+ wchar
stdbool
configure.ac:
*** modules/mbiter 26 Sep 2005 13:58:51 -0000 1.2
--- modules/mbiter 7 Jun 2007 13:25:51 -0000
***************
*** 8,13 ****
--- 8,14 ----
Depends-on:
mbchar
+ wchar
stdbool
configure.ac:
*** modules/mbuiter 26 Sep 2005 13:58:51 -0000 1.2
--- modules/mbuiter 7 Jun 2007 13:25:51 -0000
***************
*** 8,13 ****
--- 8,14 ----
Depends-on:
mbchar
+ wchar
stdbool
strnlen1
*** modules/wchar 17 May 2007 06:14:30 -0000 1.2
--- modules/wchar 7 Jun 2007 13:25:51 -0000
***************
*** 21,26 ****
--- 21,27 ----
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''ABSOLUTE_WCHAR_H''@|$(ABSOLUTE_WCHAR_H)|g' \
-e 's/@''HAVE_INCLUDE_NEXT''@/$(HAVE_INCLUDE_NEXT)/g' \
+ -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \
< $(srcdir)/wchar_.h; \
} > address@hidden
mv address@hidden $@
*** doc/headers/wchar.texi 27 Apr 2007 21:04:08 -0000 1.2
--- doc/headers/wchar.texi 7 Jun 2007 13:31:29 -0000
***************
*** 8,13 ****
--- 8,16 ----
Portability problems fixed by Gnulib:
@itemize
@item
+ This header file cannot be included on some platforms:
+ Linux uClibc built without wide character support.
+ @item
This header file is not self-contained on some platforms:
OSF/1 with Desktop Toolkit C, BSD/OS 4.0.1.
@end itemize
- printf, wchar, Simon Josefsson, 2007/06/07
- Re: printf, wchar,
Bruno Haible <=