Package: mingw32-runtime
Version: 3.13-1
Severity: normal
Tags: patch
The definition of _TSCHAR, _TUCHAR, _TXCHAR, _TINT are missing in
tchar.h. The types are normal present in tchar.h shipped by Microsoft
and other vendors, so the lack of them makes impossible to use MinGW
to compile the source code that rely on these types.
The lack of _TUCHAR is the most unfortunate, because the cast to _TUCHAR
is often necessary to guarantee that in non-UNICODE case, the argument
of character classification routines is inside of the allowed range.
For example:
_TCHAR *ptr;
if (isdigit((_TUCHAR)*ptr))
do_something();
If the cast to _TUCHAR were omitted then in non-UNICODE case (i.e. when
TCHAR is char) the argument of isdigit may become negative, which is not
allowed by the C standard.
I have attached the patch that correct this problem. In this patch, I
also moved the definition of _TCHAR inside __TCHAR_DEFINED ifdef block.
(If the _TCHAR_DEFINED macro is defined, it means that TCHAR type is
defined, while __TCHAR_DEFINED means the same for _TCHAR).
Dmitry
-- System Information:
Debian Release: lenny/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.18-6-k7 (SMP w/1 CPU core)
Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
mingw32-runtime depends on no packages.
Versions of packages mingw32-runtime recommends:
ii mingw32 4.2.1.dfsg-1 Minimalist GNU win32 (cross) compi
mingw32-runtime suggests no packages.
-- no debconf information
--- tchar.h.orig 2007-09-22 23:45:50.000000000 +0400
+++ tchar.h 2008-12-02 04:33:33.000000000 +0300
@@ -43,11 +43,21 @@
#ifndef _TCHAR_DEFINED
#ifndef RC_INVOKED
typedef wchar_t TCHAR;
-typedef wchar_t _TCHAR;
#endif /* Not RC_INVOKED */
#define _TCHAR_DEFINED
#endif
+#ifndef __TCHAR_DEFINED
+#ifndef RC_INVOKED
+typedef wchar_t _TCHAR;
+typedef wchar_t _TSCHAR;
+typedef wchar_t _TUCHAR;
+typedef wchar_t _TXCHAR;
+typedef wint_t _TINT;
+#endif /* Not RC_INVOKED */
+#define __TCHAR_DEFINED
+#endif
+
/*
* Use _TEOF instead of EOF or WEOF. It will be appropriately translated if
* _UNICODE is correctly defined (or not).
@@ -231,11 +241,21 @@
#ifndef _TCHAR_DEFINED
#ifndef RC_INVOKED
typedef char TCHAR;
-typedef char _TCHAR;
#endif
#define _TCHAR_DEFINED
#endif
+#ifndef __TCHAR_DEFINED
+#ifndef RC_INVOKED
+typedef char _TCHAR;
+typedef signed char _TSCHAR;
+typedef unsigned char _TUCHAR;
+typedef char _TXCHAR;
+typedef int _TINT;
+#endif /* Not RC_INVOKED */
+#define __TCHAR_DEFINED
+#endif
+
/*
* _TEOF, the constant you should use instead of EOF.
*/