aboutsummaryrefslogtreecommitdiff
path: root/nuttx/include/stdbool.h
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2013-01-14 21:01:58 -0800
committerpx4dev <px4@purgatory.org>2013-01-14 21:01:58 -0800
commit854c6436b4e3b292fd04843795d0369dc8856783 (patch)
tree4d5602f5c70926d2dcd01294561ddd8df4378462 /nuttx/include/stdbool.h
parent6d138a845aabad31060bd00da0d20d177d3f4be4 (diff)
parentc38ad4ded570eddadeeca3579d02dfc63dcc8a9d (diff)
downloadpx4-firmware-854c6436b4e3b292fd04843795d0369dc8856783.tar.gz
px4-firmware-854c6436b4e3b292fd04843795d0369dc8856783.tar.bz2
px4-firmware-854c6436b4e3b292fd04843795d0369dc8856783.zip
Pull NuttX up to the 6.24 release.
Merge branch 'nuttx-merge-5447'
Diffstat (limited to 'nuttx/include/stdbool.h')
-rw-r--r--nuttx/include/stdbool.h35
1 files changed, 33 insertions, 2 deletions
diff --git a/nuttx/include/stdbool.h b/nuttx/include/stdbool.h
index f11219912..9c16aee29 100644
--- a/nuttx/include/stdbool.h
+++ b/nuttx/include/stdbool.h
@@ -42,10 +42,33 @@
#include <nuttx/config.h>
+/* If CONFIG_ARCH_STDBOOL_H is set, then the archecture will provide its own
+ * stdbool.h file. In this case, this header file will simply re-direct to
+ * the architecture-specfiic stdbool.h header file.
+ */
+
#ifdef CONFIG_ARCH_STDBOOL_H
# include <arch/stdbool.h>
+
+/* NuttX will insist that the sizeof(bool) is 8-bits. The sizeof of _Bool
+ * used by any specific compiler is implementation specific: It can vary from
+ * compiler-to-compiler and even vary between different versions of the same
+ * compiler. Compilers seems to be converging to sizeof(_Bool) == 1. If that
+ * is true for your compiler, you should define CONFIG_C99_BOOL8 in your NuttX
+ * configuration for better standards compatibility.
+ *
+ * CONFIG_C99_BOOL8 - Means (1) your C++ compiler has sizeof(_Bool) == 8,
+ * (2) your C compiler supports the C99 _Bool intrinsic type, and (2) that
+ * the C99 _Bool type also has size 1.
+ */
+
#else
+
+ /* nuttx/compiler.h may also define or undefine CONFIG_C99_BOOL8 */
+
# include <nuttx/compiler.h>
+
+#if !defined(__cplusplus) || !defined(CONFIG_C99_BOOL8)
# include <stdint.h>
/****************************************************************************
@@ -58,10 +81,15 @@
* 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.
+ * use _Bool8 as the underlying type (unless CONFIG_C99_BOOL8 is defined)
*/
-#define bool _Bool8
+#ifdef CONFIG_C99_BOOL8
+# define bool _Bool
+#else
+# define bool _Bool8
+#endif
+
#define true 1
#define false 0
@@ -83,7 +111,10 @@
* as the underlying type.
*/
+#ifndef CONFIG_C99_BOOL8
typedef uint8_t _Bool8;
+#endif
+#endif /* __cplusplus && CONFIG_C99_BOOL8 */
#endif /* CONFIG_ARCH_STDBOOL_H */
#endif /* __INCLUDE_STDBOOL_H */