[PATCH v2 2/2] Fix compiling with C23 enabled compilers
Jessica Clarke
jrtc27 at jrtc27.com
Thu Dec 12 20:45:55 PST 2024
On 13 Dec 2024, at 04:14, Michael Neuling <michaelneuling at tenstorrent.com> wrote:
>
> 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;
As before:
C23’s bool is not an int, so the underlying representation of bool will
now vary based on the standard version. If you’re going to use C23’s
bool in C23, you have to use _Bool for pre-C23 to be consistent.
Jess
> +#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
>
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
More information about the opensbi
mailing list