From: Bruno Haible Date: Sun, 11 Sep 2011 18:47:03 +0000 (+0200) Subject: Fix wint_t on MSVC. X-Git-Tag: v0.1~1924 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=2210a2b11c43222262e65d7200bb094dc6d052d3;p=gnulib.git Fix wint_t on MSVC. * lib/wchar.in.h (wint_t): On MSVC, override it. * lib/wctype.in.h (wint_t): Likewise. * m4/stdint.m4 (gl_STDINT_TYPE_PROPERTIES): Override BITSIZEOF_WINT_T on MSVC. * doc/posix-headers/wchar.texi: Mention the problem with wint_t on MSVC. * doc/posix-headers/wctype.texi: Likewise. --- diff --git a/ChangeLog b/ChangeLog index 6cae13e35..8f5725ae6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2011-09-11 Bruno Haible + Fix wint_t on MSVC. + * lib/wchar.in.h (wint_t): On MSVC, override it. + * lib/wctype.in.h (wint_t): Likewise. + * m4/stdint.m4 (gl_STDINT_TYPE_PROPERTIES): Override BITSIZEOF_WINT_T on + MSVC. + * doc/posix-headers/wchar.texi: Mention the problem with wint_t on MSVC. + * doc/posix-headers/wctype.texi: Likewise. + +2011-09-11 Bruno Haible + sys_types: Fix typo. * lib/sys_types.in.h: Fix typo in comment. Reported by Paul Eggert. diff --git a/doc/posix-headers/wchar.texi b/doc/posix-headers/wchar.texi index 4fc867e85..1478244a3 100644 --- a/doc/posix-headers/wchar.texi +++ b/doc/posix-headers/wchar.texi @@ -16,6 +16,9 @@ OSF/1 with Desktop Toolkit C, BSD/OS 4.0.1. @item The type @code{wint_t} and macro @code{WEOF} are missing on some platforms: IRIX 5.3. +@item +The type @code{wint_t} is incorrect on some platforms: +MSVC 9. @item Some platforms provide a @code{NULL} macro that cannot be used in arbitrary diff --git a/doc/posix-headers/wctype.texi b/doc/posix-headers/wctype.texi index 38c239cb7..6d2e31926 100644 --- a/doc/posix-headers/wctype.texi +++ b/doc/posix-headers/wctype.texi @@ -17,6 +17,9 @@ Solaris 2.5, OSF/1 with Desktop Toolkit C, BSD/OS 4.0.1. The type @code{wint_t} and macro @code{WEOF} are missing on some platforms: IRIX 5.3. @item +The type @code{wint_t} is incorrect on some platforms: +MSVC 9. +@item The functions @code{isw*} are missing on some platforms: FreeBSD 4.11. @item diff --git a/lib/wchar.in.h b/lib/wchar.in.h index f76f371ac..8534acb78 100644 --- a/lib/wchar.in.h +++ b/lib/wchar.in.h @@ -98,6 +98,18 @@ # define WEOF -1 # endif #else +/* MSVC defines wint_t as 'unsigned short' in . + This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be + "unchanged by default argument promotions". Override it. */ +# if defined _MSC_VER +# if !GNULIB_defined_wint_t +# include +typedef unsigned int rpl_wint_t; +# undef wint_t +# define wint_t rpl_wint_t +# define GNULIB_defined_wint_t 1 +# endif +# endif # ifndef WEOF # define WEOF ((wint_t) -1) # endif diff --git a/lib/wctype.in.h b/lib/wctype.in.h index cb50c5b0e..641e991fb 100644 --- a/lib/wctype.in.h +++ b/lib/wctype.in.h @@ -79,6 +79,18 @@ # define WEOF -1 # endif #else +/* MSVC defines wint_t as 'unsigned short' in . + This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be + "unchanged by default argument promotions". Override it. */ +# if defined _MSC_VER +# if !GNULIB_defined_wint_t +# include +typedef unsigned int rpl_wint_t; +# undef wint_t +# define wint_t rpl_wint_t +# define GNULIB_defined_wint_t 1 +# endif +# endif # ifndef WEOF # define WEOF ((wint_t) -1) # endif diff --git a/m4/stdint.m4 b/m4/stdint.m4 index c75e95722..092161c99 100644 --- a/m4/stdint.m4 +++ b/m4/stdint.m4 @@ -466,6 +466,14 @@ AC_DEFUN([gl_STDINT_TYPE_PROPERTIES], fi gl_INTEGER_TYPE_SUFFIX([sig_atomic_t wchar_t wint_t], [gl_STDINT_INCLUDES]) + + dnl If wint_t is smaller than 'int', it cannot satisfy the ISO C 99 + dnl requirement that wint_t is "unchanged by default argument promotions". + dnl In this case gnulib's and override wint_t. + dnl Set the variable BITSIZEOF_WINT_T accordingly. + if test $BITSIZEOF_WINT_T -lt 32; then + BITSIZEOF_WINT_T=32 + fi ]) dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.