A testdir fails to compile on MSVC 14, because of this error: source='../../gltests/test-list-c++.cc' object='test-list-c++.obj' libtool=no \ DEPDIR=.deps depmode=msvc7 /bin/sh ../../build-aux/depcomp \ /home/bruno/msvc/compile cl -nologo -DHAVE_CONFIG_H -DEXEEXT=\".exe\" -I. -I../../gltests -I.. -DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I.. -I../../gltests/.. -I../gllib -I../../gltests/../gllib -D_WIN32_WINNT=_WIN32_WINNT_WIN7 -I/usr/local/msvc64/include -MD -c -o test-list-c++.obj `cygpath -w '../../gltests/test-list-c++.cc'` test-list-c++.cc C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xkeycheck.h(174): warning C4005: 'bool': macro redefinition ../gllib\stdbool.h(64): note: see previous definition of 'bool' C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xkeycheck.h(197): warning C4005: 'false': macro redefinition ../gllib\stdbool.h(107): note: see previous definition of 'false' C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xkeycheck.h(232): warning C4005: 'true': macro redefinition ../gllib\stdbool.h(108): note: see previous definition of 'true' C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xkeycheck.h(250): fatal error C1189: #error: The C++ Standard Library forbids macroizing keywords. Enable warning C4005 to find the forbidden macro. make[4]: *** [Makefile:23393: test-list-c++.obj] Error 2
and likewise for test-map-c++.cc, test-omap-c++.cc, test-oset-c++.cc, test-set-c++.cc. This patch fixes it. 2022-09-04 Bruno Haible <br...@clisp.org> stdbool: Fix compilation error in C++ mode with MSVC 14. * lib/stdbool.in.h (_Bool, bool, false, true): In C++ mode with MSVC 14, don't define these as macros. diff --git a/lib/stdbool.in.h b/lib/stdbool.in.h index 2fa46724b2..36f26560af 100644 --- a/lib/stdbool.in.h +++ b/lib/stdbool.in.h @@ -59,8 +59,10 @@ /* 7.16. Boolean type and values */ #ifdef __cplusplus -# define _Bool bool -# define bool bool +# if !defined _MSC_VER +# define _Bool bool +# define bool bool +# endif #else # if !defined __GNUC__ /* If @HAVE__BOOL@: @@ -103,8 +105,10 @@ typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool; /* The other macros must be usable in preprocessor directives. */ #ifdef __cplusplus -# define false false -# define true true +# if !defined _MSC_VER +# define false false +# define true true +# endif #else # define false 0 # define true 1