9.51 stdbool.h ¶
POSIX specification:
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/stdbool.h.html
Gnulib module: stdbool-h-c99
The stdbool-h-c99
module is present only for programs that
formerly used the old stdbool
module for C99 compatibility,
and that for some reason cannot use the current bool
module
for C23 compatibility.
Portability problems fixed by Gnulib:
- This header file is missing on some platforms:
AIX 5.1, HP-UX 11.
- This header file is not usable in C++ mode with the vendor compiler
on Solaris 10.
- Some compilers have bugs relating to ‘bool’.
- This header file defines
true
incorrectly on some platforms:
OpenBSD 4.7 with gcc 2.95.
Portability problems not fixed by Gnulib:
- ‘_Bool’ cannot be used before
<stdbool.h>
is included, or if
the program is intended to be compiled by a C++ compiler.
(With the advent of C23, ‘_Bool’ is obsolescent anyway.)
- You cannot assume that
_Bool
is a typedef; it might be a macro.
For example, C23 allows _Bool
to be a macro.
- Bit-fields of type ‘bool’ are not supported. Portable code
should use ‘unsigned int foo : 1;’ rather than ‘bool foo : 1;’.
- Casts and automatic conversions to ‘bool’ don’t test against the
zero value or the null pointer, as they should. Such casts should only
be used if the value is known to be equal to 0 or 1.
- You cannot assume that casting a floating point literal to ‘bool’ will
result in a constant expression.