Browse Source

Make stdbool.h C++ compatiable

The problem here is that _Bool type is not defined in C++ yet this file
is using it. That leads to issues when compiling gcc. I borrowed the
same techniques used in other stdbool.h
oddcoder 4 years ago
parent
commit
a125b8be15
1 changed files with 10 additions and 0 deletions
  1. 10 0
      include/stdbool.h

+ 10 - 0
include/stdbool.h

@@ -1,9 +1,19 @@
 #ifndef _STDBOOL_H
 #define _STDBOOL_H
 
+#ifndef __cplusplus
 typedef _Bool bool;
 #define true 1
 #define false 0
+#else /* __cplusplus */
+typedef bool _Bool;
+#if __cplusplus < 201103L
+#define false false
+#define true true
+#endif /*__cplusplus < 201103L*/
+#endif /* __cplusplus */
+
 #define __bool_true_false_are_defined 1
 
+
 #endif /* _STDBOOL_H */