FreeBSD 15.1 was released two days ago. It adds the <stdbit.h> header file,
see <https://www.freebsd.org/releases/15.1R/relnotes/#userland-libraries>.
But this header file is buggy: It produces syntax errors in C++ mode.
depbase=`echo test-stdbit-h-c++.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`; c++
-ferror-limit=0 -DHAVE_CONFIG_H -DEXEEXT=\"\" -DEXEEXT=\"\" -I. -I../../gltests
-I.. -DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests
-I.. -I../../gltests/.. -I../gllib -I../../gltests/../gllib
-I/home/bruno/include -I/usr/local/include -Wall -D_THREAD_SAFE -Wno-error
-Wno-error -g -O2 -MT test-stdbit-h-c++.o -MD -MP -MF $depbase.Tpo -c -o
test-stdbit-h-c++.o ../../gltests/test-stdbit-h-c++.cc && mv -f $depbase.Tpo
$depbase.Po
In file included from ../../gltests/test-stdbit-h-c++.cc:22:
In file included from ../gllib/stdbit.h:30:
/usr/include/stdbit.h:115:1: error: unknown type name '_Bool'
115 | _Bool stdc_has_single_bit_uc(unsigned char) __pure2;
| ^
/usr/include/stdbit.h:116:1: error: unknown type name '_Bool'
116 | _Bool stdc_has_single_bit_us(unsigned short) __pure2;
| ^
/usr/include/stdbit.h:117:1: error: unknown type name '_Bool'
117 | _Bool stdc_has_single_bit_ui(unsigned int) __pure2;
| ^
/usr/include/stdbit.h:118:1: error: unknown type name '_Bool'
118 | _Bool stdc_has_single_bit_ul(unsigned long) __pure2;
| ^
/usr/include/stdbit.h:119:1: error: unknown type name '_Bool'
119 | _Bool stdc_has_single_bit_ull(unsigned long long) __pure2;
| ^
This patch provides a workaround.
2026-06-18 Bruno Haible <[email protected]>
stdbit-h: Work around syntax error in FreeBSD 15.1 <stdbit.h>.
* lib/stdbit.in.h (_Bool): Define on FreeBSD in C++ mode.
* doc/posix-headers/stdbit.texi: Mention the FreeBSD bug.
diff --git a/doc/posix-headers/stdbit.texi b/doc/posix-headers/stdbit.texi
index 2788af8944..9a1ab3ac03 100644
--- a/doc/posix-headers/stdbit.texi
+++ b/doc/posix-headers/stdbit.texi
@@ -13,11 +13,14 @@
@itemize
@item
This header file is missing on many non-C23 platforms:
-glibc 2.38, macOS 14, FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.9, AIX 7.3.1, HP-UX
11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15.
+glibc 2.38, macOS 14, FreeBSD 15.0, NetBSD 10.0, OpenBSD 7.9, AIX 7.3.1, HP-UX
11.31, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 17, Android 15.
@item
This header file exists but is a no-op:
G++ 15.2.
@item
+This header file has syntax errors in C++ mode on some platforms:
+FreeBSD 15.1.
+@item
This header file does not define the necessary types
with the Intel @code{icpx} C++ compiler.
@end itemize
diff --git a/lib/stdbit.in.h b/lib/stdbit.in.h
index c7047e3297..d9a873a43a 100644
--- a/lib/stdbit.in.h
+++ b/lib/stdbit.in.h
@@ -26,6 +26,10 @@
/* The include_next requires a split double-inclusion guard. */
#if @HAVE_STDBIT_H@
+/* The FreeBSD 15.1 <stdbit.h> uses the _Bool type. */
+# if defined __FreeBSD__ && defined __cplusplus
+# define _Bool bool
+# endif
# @INCLUDE_NEXT@ @NEXT_STDBIT_H@
#endif