In a GNU gettext build with MSVC 19.35 (Visual Studio 2022), I see
several compilation errors:

/home/bruno/msvc/compile cl -nologo -std:c11 -DHAVE_CONFIG_H -DEXEEXT=\".exe\" 
-I. -I../../../gettext-runtime/gnulib-lib -I..  -I../intl 
-DDEPENDS_ON_LIBICONV=1 -DDEPENDS_ON_LIBINTL=1 -D_WIN32_WINNT=_WIN32_WINNT_WIN7 
-I/usr/local/msvc64/include    -MD -c -o libgrt_a-fzprintf.obj `if test -f 
'fzprintf.c'; then cygpath -w 'fzprintf.c'; else cygpath -w 
'../../../gettext-runtime/gnulib-lib/fzprintf.c'; fi`
fzprintf.c
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-runtime\gnulib-lib\fzprintf.c(51):
 error C7700: type 'char' in _Generic association compatible with previous 
association type 'char'
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-runtime\gnulib-lib\fzprintf.c(51):
 note: _Generic compatible type previously 'char' specified here
make[6]: *** [Makefile:4117: libgrt_a-fzprintf.obj] Error 2

libtool: compile:  /home/bruno/msvc/compile cl -nologo -std:c11 -DHAVE_CONFIG_H 
-DEXEEXT=\".exe\" -DEXEEXT=\".exe\" -DEXEEXT=\".exe\" -I. 
-I../../../gettext-tools/gnulib-lib -I.. -I../../gettext-runtime/intl 
-I../../../gettext-tools -DIN_LIBGETTEXTLIB -DDEPENDS_ON_LIBICONV=1 
-DDEPENDS_ON_LIBINTL=1 -DLIBXML_STATIC -D_WIN32_WINNT=_WIN32_WINNT_WIN7 
-I/usr/local/msvc64/include -MD -c -showIncludes 
../../../gettext-tools/gnulib-lib/xstrtol.c -o libgettextlib_la-xstrtol.obj
xstrtol.c
../../../gettext-tools/gnulib-lib/xstrtol.c(52): error C7700: type 'char' in 
_Generic association compatible with previous association type 'char'
../../../gettext-tools/gnulib-lib/xstrtol.c(52): note: _Generic compatible type 
previously 'char' specified here
../../../gettext-tools/gnulib-lib/xstrtol.c(52): error C7700: type 'char' in 
_Generic association compatible with previous association type 'char'
../../../gettext-tools/gnulib-lib/xstrtol.c(52): note: _Generic compatible type 
previously 'char' specified here
../../../gettext-tools/gnulib-lib/xstrtol.c(77): error C7700: type 'char' in 
_Generic association compatible with previous association type 'char'
../../../gettext-tools/gnulib-lib/xstrtol.c(77): note: _Generic compatible type 
previously 'char' specified here

libtool: compile:  /home/bruno/msvc/compile cl -nologo -std:c11 -DHAVE_CONFIG_H 
-DEXEEXT=\".exe\" -DEXEEXT=\".exe\" -DEXEEXT=\".exe\" -I. 
-I../../../gettext-tools/gnulib-lib -I.. -I../../gettext-runtime/intl 
-I../../../gettext-tools -DIN_LIBGETTEXTLIB -DDEPENDS_ON_LIBICONV=1 
-DDEPENDS_ON_LIBINTL=1 -DLIBXML_STATIC -D_WIN32_WINNT=_WIN32_WINNT_WIN7 
-I/usr/local/msvc64/include -MD -c -showIncludes 
../../../gettext-tools/gnulib-lib/xstrtoul.c -o libgettextlib_la-xstrtoul.obj
xstrtoul.c
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-lib\xstrtol.c(52):
 error C7700: type 'char' in _Generic association compatible with previous 
association type 'char'
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-lib\xstrtol.c(52):
 note: _Generic compatible type previously 'char' specified here
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-lib\xstrtol.c(52):
 error C7700: type 'char' in _Generic association compatible with previous 
association type 'char'
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-lib\xstrtol.c(52):
 note: _Generic compatible type previously 'char' specified here
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-lib\xstrtol.c(77):
 error C7700: type 'char' in _Generic association compatible with previous 
association type 'char'
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-lib\xstrtol.c(77):
 note: _Generic compatible type previously 'char' specified here
make[5]: *** [Makefile:10374: libgettextlib_la-xstrtoul.lo] Error 1

/home/bruno/msvc/compile cl -nologo -std:c11 -DHAVE_CONFIG_H -I. 
-I../../../../gettext-tools/libgrep/gnulib-lib -I../..  
-I../../../gettext-runtime/intl -I../../gnulib-lib 
-I../../../../gettext-tools/gnulib-lib -DIN_GETTEXT_TOOLS_LIBGREP=1 
-D_WIN32_WINNT=_WIN32_WINNT_WIN7 -I/usr/local/msvc64/include    -MD -c -o 
libgnu_a-regex.obj `if test -f 'regex.c'; then cygpath -w 'regex.c'; else 
cygpath -w '../../../../gettext-tools/libgrep/gnulib-lib/regex.c'; fi`
regex.c
.\wctype.h(1180): note: see previous definition of 'wctype_t'
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\libgrep\gnulib-lib\regcomp.c(2626):
 error C7700: type 'char' in _Generic association compatible with previous 
association type 'char'
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\libgrep\gnulib-lib\regcomp.c(2626):
 note: _Generic compatible type previously 'char' specified here
make[7]: *** [Makefile:5076: libgnu_a-regex.obj] Error 2

/home/bruno/msvc/compile cl -nologo -std:c11 -DHAVE_CONFIG_H -DEXEEXT=\".exe\" 
-DEXEEXT=\".exe\" -I. -I../../../gettext-tools/gnulib-tests -I..  
-DIN_GETTEXT_TOOLS_GNULIB_TESTS=1 -I. -I../../../gettext-tools/gnulib-tests 
-I.. -I../../../gettext-tools/gnulib-tests/.. -I../gnulib-lib 
-I../../../gettext-tools/gnulib-tests/../gnulib-lib 
-I../../gettext-runtime/intl -D_WIN32_WINNT=_WIN32_WINNT_WIN7 
-I/usr/local/msvc64/include   -MD -c -o dtotimespec.obj `cygpath -w 
'../../../gettext-tools/gnulib-tests/dtotimespec.c'`
dtotimespec.c
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\dtotimespec.c(32):
 error C7700: type 'char' in _Generic association compatible with previous 
association type 'char'
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\dtotimespec.c(32):
 note: _Generic compatible type previously 'char' specified here
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\dtotimespec.c(33):
 error C7700: type 'char' in _Generic association compatible with previous 
association type 'char'
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\dtotimespec.c(33):
 note: _Generic compatible type previously 'char' specified here
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\dtotimespec.c(34):
 error C7700: type 'char' in _Generic association compatible with previous 
association type 'char'
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\dtotimespec.c(34):
 note: _Generic compatible type previously 'char' specified here
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\dtotimespec.c(35):
 error C7700: type 'char' in _Generic association compatible with previous 
association type 'char'
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\dtotimespec.c(35):
 note: _Generic compatible type previously 'char' specified here
make[6]: *** [Makefile:11164: dtotimespec.obj] Error 2

/home/bruno/msvc/compile cl -nologo -std:c11 -DHAVE_CONFIG_H -DEXEEXT=\".exe\" 
-DEXEEXT=\".exe\" -I. -I../../../gettext-tools/gnulib-tests -I..  
-DIN_GETTEXT_TOOLS_GNULIB_TESTS=1 -I. -I../../../gettext-tools/gnulib-tests 
-I.. -I../../../gettext-tools/gnulib-tests/.. -I../gnulib-lib 
-I../../../gettext-tools/gnulib-tests/../gnulib-lib 
-I../../gettext-runtime/intl -D_WIN32_WINNT=_WIN32_WINNT_WIN7 
-I/usr/local/msvc64/include   -MD -c -o timespec-add.obj `cygpath -w 
'../../../gettext-tools/gnulib-tests/timespec-add.c'`
timespec-add.c
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\timespec-add.c(41):
 error C7700: type 'char' in _Generic association compatible with previous 
association type 'char'
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\timespec-add.c(41):
 note: _Generic compatible type previously 'char' specified here
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\timespec-add.c(41):
 error C7700: type 'char' in _Generic association compatible with previous 
association type 'char'
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\timespec-add.c(41):
 note: _Generic compatible type previously 'char' specified here
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\timespec-add.c(43):
 error C7700: type 'char' in _Generic association compatible with previous 
association type 'char'
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\timespec-add.c(43):
 note: _Generic compatible type previously 'char' specified here
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\timespec-add.c(48):
 error C7700: type 'char' in _Generic association compatible with previous 
association type 'char'
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\timespec-add.c(48):
 note: _Generic compatible type previously 'char' specified here
make[6]: *** [Makefile:11164: timespec-add.obj] Error 2

/home/bruno/msvc/compile cl -nologo -std:c11 -DHAVE_CONFIG_H -DEXEEXT=\".exe\" 
-DEXEEXT=\".exe\" -I. -I../../../gettext-tools/gnulib-tests -I..  
-DIN_GETTEXT_TOOLS_GNULIB_TESTS=1 -I. -I../../../gettext-tools/gnulib-tests 
-I.. -I../../../gettext-tools/gnulib-tests/.. -I../gnulib-lib 
-I../../../gettext-tools/gnulib-tests/../gnulib-lib 
-I../../gettext-runtime/intl -D_WIN32_WINNT=_WIN32_WINNT_WIN7 
-I/usr/local/msvc64/include   -MD -c -o timespec-sub.obj `cygpath -w 
'../../../gettext-tools/gnulib-tests/timespec-sub.c'`
timespec-sub.c
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\timespec-sub.c(42):
 error C7700: type 'char' in _Generic association compatible with previous 
association type 'char'
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\timespec-sub.c(42):
 note: _Generic compatible type previously 'char' specified here
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\timespec-sub.c(42):
 error C7700: type 'char' in _Generic association compatible with previous 
association type 'char'
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\timespec-sub.c(42):
 note: _Generic compatible type previously 'char' specified here
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\timespec-sub.c(44):
 error C7700: type 'char' in _Generic association compatible with previous 
association type 'char'
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\timespec-sub.c(44):
 note: _Generic compatible type previously 'char' specified here
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\timespec-sub.c(49):
 error C7700: type 'char' in _Generic association compatible with previous 
association type 'char'
C:\cygwin64\home\bruno\gettext-20260512-static\gettext-tools\gnulib-tests\timespec-sub.c(49):
 note: _Generic compatible type previously 'char' specified here
make[6]: *** [Makefile:11164: timespec-sub.obj] Error 2

In other words, all uses of the macros
  TYPE_MAXIMUM
  TYPE_MINIMUM
  TYPE_SIGNED
generate errors.

This is obviously caused by the commit "intprops: ignore -Wuseless-cast less 
often".

The conflict is between 'char' and 'signed char'. ('bool' is fine.)

"/home/bruno/msvc/compile cl -nologo -std:c11" (which translates to
"cl -std:c11") apparently defines __STDC_VERSION__ to 201112, but without
implementing _Generic correctly regarding 'char' vs. 'signed char'.

It is fine with newer MSVC (14.44, cf. the table at
<https://learn.microsoft.com/en-us/cpp/overview/compiler-versions>),
i.e. with _MSC_VER >= 1944.

This patch fixes all the errors.


2026-05-13  Bruno Haible  <[email protected]>

        intprops: Fix compilation error in MSVC.
        * lib/intprops.h (TYPE_IS_INTEGER, TYPE_MINIMUM, TYPE_MAXIMUM): Don't
        use _Generic to distinguish between 'char' and 'signed char' with MSVC
        before version 14.44.
        * lib/intprops-internal.h (_GL_TYPE_SIGNED): Likewise.

diff --git a/lib/intprops-internal.h b/lib/intprops-internal.h
index f569d94a06..1fb3b79901 100644
--- a/lib/intprops-internal.h
+++ b/lib/intprops-internal.h
@@ -50,7 +50,8 @@
    e.g., in Cray C 5.0.3.0.  */
 
 /* True if the standard integer or standard real type T is signed.  */
-#if __STDC_VERSION__ < 201112 || _GL__GENERIC_BOGUS
+#if (__STDC_VERSION__ < 201112 || (defined _MSC_VER && _MSC_VER < 1944) \
+     || _GL__GENERIC_BOGUS)
 # define _GL_TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
 #else
 /* Pacify -Wuseless-cast, but do not default to the simpler expression;
diff --git a/lib/intprops.h b/lib/intprops.h
index ed6df2dbc3..8279cd73e3 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -25,7 +25,8 @@
 
 /* True if the arithmetic type T is an integer type.  bool counts as
    an integer.  */
-#if __STDC_VERSION__ < 201112 || _GL__GENERIC_BOGUS
+#if (__STDC_VERSION__ < 201112 || (defined _MSC_VER && _MSC_VER < 1944) \
+     || _GL__GENERIC_BOGUS)
 # define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
 #else
 /* Pacify -Wuseless-cast and do not default to the simpler expression;
@@ -62,7 +63,8 @@
 #define TYPE_WIDTH(t) _GL_TYPE_WIDTH (t)
 
 /* The maximum and minimum values for the standard integer type T.  */
-#if __STDC_VERSION__ < 201112 || _GL__GENERIC_BOGUS
+#if (__STDC_VERSION__ < 201112 || (defined _MSC_VER && _MSC_VER < 1944) \
+     || _GL__GENERIC_BOGUS)
 # define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
 # define TYPE_MAXIMUM(t)                                                \
    ((t) (! TYPE_SIGNED (t)                                              \




Reply via email to