Names specified here
Name Description Notes Source Availability
_Bool Boolean type L T Keyword C99 C11
ATOMIC_BOOL_LOCK_FREE Lock-free property of type atomic_bool ? M <stdatomic.h> C11
atomic_bool Atomic boolean type ? T <stdatomic.h> C11
Names specified for <stdbool.h>, “Boolean type”
Name Description Notes Source Availability
__bool_true_false_are_defined Indicate availability of boolean type L M <stdbool.h> C99 C11
bool Boolean type L M T <stdbool.h> C99 C11
false Boolean constant ‘false’ L M <stdbool.h> C99 C11
true Boolean constant ‘true’ L M <stdbool.h> C99 C11

This header is available in C99 and C11.

A Boolean expression or condition is an expression whose value is interpreted as either true or false. Boolean conditions are expected in several places:

In these cases, any scalar expression may be given. A real value is first converted to an integer by truncation, and the integer value is compared with 0. If equal, the expression is considered false; otherwise true.

int is typically used to store or pass a Boolean value, with zero meaning false, and all other values meaning true. However, from C99, the native type _Bool is defined as a 1-bit unsigned integer type, capable of holding only 0 or 1. Any value of scalar type converted to _Bool is interpreted as 1 if it is non-zero.

The header <stdbool.h> then defines several macros to improve readability of Boolean values and types:

#define bool _Bool
#define false 0
#define true 1
#define __bool_true_false_are_defined 1

The ability to #undef bool, true or false is obsolescent. Future standards may make such actions an error.

In <stdatomic.h>, atomic_bool is an alias for _Atomic _Bool. This type is lock-free always if ATOMIC_BOOL_LOCK_FREE is 2, sometimes if 1, and never if 0.


CHaR
Sitemap Supported
Site format updated 2024-06-05T22:37:07.391+0000
Data updated 1970-01-01T00:00:00.000+0000
Page updated 2023-10-04T20:24:03.213+0000