HP C A.06.05 Reference Manual
Data Types and Declarations
_Bool
Chapter 342
_Bool
This release supports the boolean data type _Bool. The variables of the data type _Bool can
only have values true(1) or false(0), where true and false are preprocessor macros defined in
the header file stdbool.h. The _Bool data type is a part of C99 standard (ISO/IEC
9899:1999). The C99 standard specifies boolean bitfields. For example: _Bool can be defined as
in the following structure declaration:
struct foo {
_Bool boolval:1;
int i;
}
Since _Bool is defined to take only 0 and 1 as values, this type of _Bool declaration has some
special properties, such as:
_Bool flip_flop = 0; // flip_flop is now false
++flip_flop; // flip_flop is now true
++flip_flop; // flip_flop is true
--flip_flop; // flip_flop is now false
--flip_flop; // flip_flop is now true
New Header file
The default location for <stdbool.h> is /usr/include. This header file is available in patch
PHSS_24204 (for HP-UX 11.00) and PHSS_24205 (for HP-UX 11.11). This header file includes
the following four macros:
• bool expands to _Bool.
• true expands to integer constant 1.
• false expands to integer constant 0.
• __bool_true_false_are_defined expands to decimal constant 1.
The last three macros are suitable for use in #if preprocessor directives.
Usage of _Bool
Observe the following while using _Bool:
• The rank of _Bool is less than the rank of all other standard integer types.