> 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 <[email protected]> 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 <[email protected]>. 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.
