bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Overriding the MS-Windows wint_t type considered harmful


From: Bruno Haible
Subject: Re: Overriding the MS-Windows wint_t type considered harmful
Date: Mon, 01 May 2017 12:59:04 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-75-generic; KDE/5.18.0; x86_64; ; )

> One scenario where this gets in the way is when the application
> includes some other header, e.g. ctype.h, which declares the same isw*
> functions as wchar.h and wctype.h -- if the inclusion of ctype.h is
> _after_ wchar.h/wctype.h are included, this produces compilation
> errors, because the prototypes of the isw* functions were first seen
> with the original wint_t type, and now are seen with the wider wint_t.

Thanks for the report. The case of <ctype.h> after <wctype.h> was already
handled for mingw. Here's a patch to cover the case <wchar.h> after <wctype.h>
as well.


2017-05-01  Bruno Haible  <address@hidden>

        wctype: Fix problems if <wchar.h> gets included after <wctype.h>.
        * lib/wctype.in.h: Include not only <ctype.h> but also <wchar.h>. Do so
        also on MSVC.
        Reported by Eli Zaretskii <address@hidden>.

diff --git a/lib/wctype.in.h b/lib/wctype.in.h
index 933bf78..759659b 100644
--- a/lib/wctype.in.h
+++ b/lib/wctype.in.h
@@ -56,11 +56,13 @@
 # include <wchar.h>
 #endif
 
-/* mingw has declarations of towupper and towlower in <ctype.h> as
-   well <wctype.h>.  Include <ctype.h> in advance to avoid rpl_ prefix
-   being added to the declarations.  */
-#ifdef __MINGW32__
+/* Native Windows (mingw, MSVC) have declarations of towupper, towlower, and
+   isw* functions in <ctype.h>, <wchar.h> as well as in <wctype.h>.  Include
+   <ctype.h>, <wchar.h> in advance to avoid rpl_ prefix being added to the
+   declarations.  */
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
 # include <ctype.h>
+# include <wchar.h>
 #endif
 
 /* Include the original <wctype.h> if it exists.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]