diff --git a/include/stdbool.h b/include/stdbool.h index fad1c30801..d1c06ffe12 100755 --- a/include/stdbool.h +++ b/include/stdbool.h @@ -51,9 +51,14 @@ /* bool, true, and false must be provided as macros so that they can be * redefined by the application if necessary. + * + * NOTE: Under C99 'bool' is required to be defined to be the intrinsic type + * _Bool. However, in this NuttX context, we need backward compatibility + * to pre-C99 standards where _Bool is not an intrinsic type. Hence, we + * use _Bool8 as the underlying type. */ -#define bool _Bool +#define bool _Bool8 #define true 1 #define false 0 @@ -64,10 +69,17 @@ ****************************************************************************/ /* A byte is the smallest address memory element (at least in architectures - * that do not support bit banding. We select uint8_t versus the more standard - * int as the underlying type to minimize the RAM footprint of the executable. + * that do not support bit banding). The requirement is only that type _Bool + * be large enough to hold the values 0 and 1. We select uint8_t to minimize + * the RAM footprint of the executable. + * + * NOTE: We can't actually define the type _Bool here. Under C99 _Bool is + * an intrinsic type and cannot be the target of a typedef. However, in this + * NuttX context, we also need backward compatibility to pre-C99 standards + * where _Bool is not an intrinsic type. We work around this by using _Bool8 + * as the underlying type. */ -typedef uint8_t _Bool; +typedef uint8_t _Bool8; #endif /* __INCLUDE_STDBOOL_H */