]> Savannah Git Hosting - gnulib.git/commitdiff
Fix wint_t on MSVC.
authorBruno Haible <bruno@clisp.org>
Sun, 11 Sep 2011 18:47:03 +0000 (20:47 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 11 Sep 2011 18:47:03 +0000 (20:47 +0200)
* 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.

ChangeLog
doc/posix-headers/wchar.texi
doc/posix-headers/wctype.texi
lib/wchar.in.h
lib/wctype.in.h
m4/stdint.m4

index 6cae13e353247483e7cd250006162809b99b8774..8f5725ae6db60e9d52948d37b05d902747fdd166 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-09-11  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        sys_types: Fix typo.
index 4fc867e85fa9d9fb3596ca6d6bdcdbdf607a61f2..1478244a363da5e211bf329327cf0fa3cb8d7905 100644 (file)
@@ -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
index 38c239cb73f4fff06ea3d9a0ca4d2ab1aaad0299..6d2e31926f4a423010eb71e29261c1980b85d7b9 100644 (file)
@@ -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
index f76f371ace52a288f2d481fbe3ee51a7dd82d9eb..8534acb789447985cf4ddabea9b552a1b3160dde 100644 (file)
 #  define WEOF -1
 # endif
 #else
+/* MSVC defines wint_t as 'unsigned short' in <crtdefs.h>.
+   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 <crtdefs.h>
+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
index cb50c5b0ef957ea20f7c6a731a62133ccf2246b5..641e991fb5af4578bab9221646fe676b8588803b 100644 (file)
 #  define WEOF -1
 # endif
 #else
+/* MSVC defines wint_t as 'unsigned short' in <crtdefs.h>.
+   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 <crtdefs.h>
+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
index c75e95722a58eee3f1f9ded938d4036ad45d3759..092161c9968b23ef8151e97b7ac466ea540ca36d 100644 (file)
@@ -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 <wchar.h> and <wctype.h> 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.