bug-gnulib
[Top][All Lists]
Advanced

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

Gnulib's wctype.h fails to compile with MinGW


From: Eli Zaretskii
Subject: Gnulib's wctype.h fails to compile with MinGW
Date: Thu, 27 Apr 2017 17:44:58 +0300

Building the recent pretest of Texinfo 6.4 with mingw.org's MinGW
fails:

     gcc -static-libgcc -DHAVE_CONFIG_H -I. -I../..    -Id:/usr/include  -O2 
-gdwarf-4 -g3 -MT mbchar.o -MD -MP -MF $depbase.Tpo -c -o mbchar.o mbchar.c &&\
     mv -f $depbase.Tpo $depbase.Po
     In file included from d:\usr\include\wchar.h:44:0,
                      from ./wchar.h:87,
                      from mbchar.h:156,
                      from mbchar.c:23:
     ./wctype.h:539:24: fatal error: crtdefs.h: No such file or directory
     compilation terminated.
     Makefile:1399: recipe for target `mbchar.o' failed
     make[4]: *** [mbchar.o] Error 1

This happens because gnulib/lib/wctype.h does this:

     #else
     /* mingw and MSVC define 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 1
     #  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

But mingw.org's MinGW headers don't have crtdefs.h.  The wint_t type
is defined in stddef.h there.

I propose the following to fix this:

diff --git a/lib/wctype.in.h b/lib/wctype.in.h
index d307630..70bd4d2 100644
--- a/lib/wctype.in.h
+++ b/lib/wctype.in.h
@@ -105,12 +105,21 @@ _GL_INLINE_HEADER_BEGIN
 #  define WEOF -1
 # endif
 #else
-/* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h>.
+/* mingw and MSVC define wint_t as 'unsigned short' in <crtdefs.h>/<stddef.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 @GNULIB_OVERRIDES_WINT_T@
 #  if !GNULIB_defined_wint_t
-#   include <crtdefs.h>
+#   ifdef __MINGW32__
+#    include <_mingw.h>
+#    ifdef __MINGW64_VERSION_MAJOR
+#     include <crtdefs.h>
+#    else
+#     include <stddef.h>
+#    endif
+#   else
+#    include <crtdefs.h>
+#   endif
 typedef unsigned int rpl_wint_t;
 #   undef wint_t
 #   define wint_t rpl_wint_t




reply via email to

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