[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
wchar.h, wctype.h: fix wint_t on MSVC
From: |
Bruno Haible |
Subject: |
wchar.h, wctype.h: fix wint_t on MSVC |
Date: |
Sun, 11 Sep 2011 20:49:11 +0200 |
User-agent: |
KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; ) |
The choice of wint_t on MSVC ('unsigned short') violates ISO C 99. We need to
change it to 'unsigned int' instead.
2011-09-11 Bruno Haible <address@hidden>
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.
--- doc/posix-headers/wchar.texi.orig Sun Sep 11 20:45:43 2011
+++ doc/posix-headers/wchar.texi Sun Sep 11 19:16:48 2011
@@ -16,6 +16,9 @@
@item
The type @code{wint_t} and macro @code{WEOF} are missing on some platforms:
IRIX 5.3.
address@hidden
+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
--- doc/posix-headers/wctype.texi.orig Sun Sep 11 20:45:43 2011
+++ doc/posix-headers/wctype.texi Sun Sep 11 19:16:40 2011
@@ -17,6 +17,9 @@
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.
address@hidden
The functions @code{isw*} are missing on some platforms:
FreeBSD 4.11.
@item
--- lib/wchar.in.h.orig Sun Sep 11 20:45:43 2011
+++ lib/wchar.in.h Sun Sep 11 19:23:09 2011
@@ -98,6 +98,18 @@
# 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
--- lib/wctype.in.h.orig Sun Sep 11 20:45:43 2011
+++ lib/wctype.in.h Sun Sep 11 19:23:09 2011
@@ -79,6 +79,18 @@
# 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
--- m4/stdint.m4.orig Sun Sep 11 20:45:43 2011
+++ m4/stdint.m4 Sun Sep 11 19:48:14 2011
@@ -466,6 +466,14 @@
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.
--
In memoriam Georgi Markov <http://en.wikipedia.org/wiki/Georgi_Markov>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- wchar.h, wctype.h: fix wint_t on MSVC,
Bruno Haible <=