summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-05-13 19:28:35 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-05-13 19:30:41 +0900
commit1d0cfb359c5a0c482c25e5fada987148738012ad (patch)
treead455fcc5f4b98d3e389c5244b805a26385c9e9c
parent3a3761ec699d7ae71d858024d8e6748f325f14a8 (diff)
downloadmruby-1d0cfb359c5a0c482c25e5fada987148738012ad.tar.gz
mruby-1d0cfb359c5a0c482c25e5fada987148738012ad.zip
Update `mrb_bool` definition; close #2385
- move `TRUE/FALSE` definition from `mrbconf.h` (not configurable) - use C/C++ definition of boolean type for `mrb_bool` The fix is originally written by @take-cheeze.
-rw-r--r--include/mrbconf.h8
-rw-r--r--include/mruby/value.h23
2 files changed, 23 insertions, 8 deletions
diff --git a/include/mrbconf.h b/include/mrbconf.h
index d4da81bfc..2a320f371 100644
--- a/include/mrbconf.h
+++ b/include/mrbconf.h
@@ -181,14 +181,6 @@
# include <stdio.h>
#endif
-#ifndef FALSE
-# define FALSE 0
-#endif
-
-#ifndef TRUE
-# define TRUE 1
-#endif
-
/*
** mruby tuning profiles
**/
diff --git a/include/mruby/value.h b/include/mruby/value.h
index 39c01509d..841cc7e6e 100644
--- a/include/mruby/value.h
+++ b/include/mruby/value.h
@@ -31,7 +31,30 @@ typedef uint32_t mrb_sym;
* Not to be confused with Ruby's boolean classes, which can be
* obtained using mrb_false_value() and mrb_true_value()
*/
+#if defined(__cplusplus) || (defined(__bool_true_false_are_defined) && __bool_true_false_are_defined)
+typedef bool mrb_bool;
+
+# ifndef FALSE
+# define FALSE false
+# endif
+# ifndef TRUE
+# define TRUE true
+# endif
+#else
+# if __STDC_VERSION__ >= 199901L
+typedef _Bool mrb_bool;
+# else
typedef uint8_t mrb_bool;
+# endif
+
+# ifndef FALSE
+# define FALSE 0
+# endif
+# ifndef TRUE
+# define TRUE 1
+# endif
+#endif
+
struct mrb_state;
#if defined _MSC_VER && _MSC_VER < 1800