[PATCH v2 2/2] Fix compiling with C23 enabled compilers

Michael Neuling michaelneuling at tenstorrent.com
Thu Dec 12 20:14:21 PST 2024


C23 pre-definies bool so we need to gate our defines.

Signed-off-by: Michael Neuling <michaelneuling at tenstorrent.com>
---
 include/sbi/sbi_types.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/sbi/sbi_types.h b/include/sbi/sbi_types.h
index a9943d299c..f051695ffd 100644
--- a/include/sbi/sbi_types.h
+++ b/include/sbi/sbi_types.h
@@ -44,7 +44,12 @@ typedef unsigned long long	uint64_t;
 #error "Unexpected __riscv_xlen"
 #endif
 
+#if __STDC_VERSION__ < 202311L
 typedef int			bool;
+#define true			1
+#define false			0
+#endif
+
 typedef unsigned long		ulong;
 typedef unsigned long		uintptr_t;
 typedef unsigned long		size_t;
@@ -61,9 +66,6 @@ typedef uint32_t		be32_t;
 typedef uint64_t		le64_t;
 typedef uint64_t		be64_t;
 
-#define true			1
-#define false			0
-
 #define NULL			((void *)0)
 
 #define __packed		__attribute__((packed))
-- 
2.34.1




More information about the opensbi mailing list