From d969b4bc27a4838376fa229c87809b1e015c4cfe Mon Sep 17 00:00:00 2001 From: Jonathon Penix Date: Wed, 26 Mar 2025 15:55:50 -0700 Subject: [PATCH] toolchain: llvm: Use clang's __INTN_C/__UINTN_C macros for clang 20+ clang recently began providing predefined __INTN_C/__UINTN_C macros resulting in macro redefinition warnings in toolchain/llvm.h. This change was landed in clang in late Jan. 2025 and clang/LLVM 20 is the first official release that has this support (see the PR linked below). Prefer the definitions provided by clang and avoid redefining these macros for clang versions 20 and later to avoid said warnings. Link: https://github.com/llvm/llvm-project/pull/123514 Signed-off-by: Jonathon Penix --- include/zephyr/toolchain/llvm.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/zephyr/toolchain/llvm.h b/include/zephyr/toolchain/llvm.h index cc131246d0a8b..e093efc3520af 100644 --- a/include/zephyr/toolchain/llvm.h +++ b/include/zephyr/toolchain/llvm.h @@ -41,6 +41,12 @@ */ #ifdef CONFIG_MINIMAL_LIBC +/* + * Predefined __INTN_C/__UINTN_C macros are provided by clang starting in version 20. + * Avoid redefining these macros if a sufficiently modern clang is being used. + */ +#if __clang_major__ < 20 + #define __int_c(v, suffix) v ## suffix #define int_c(v, suffix) __int_c(v, suffix) #define uint_c(v, suffix) __int_c(v ## U, suffix) @@ -132,6 +138,8 @@ #define __INTMAX_C(x) int_c(x, __INTMAX_C_SUFFIX__) #define __UINTMAX_C(x) int_c(x, __UINTMAX_C_SUFFIX__) +#endif /* __clang_major__ < 20 */ + #endif /* CONFIG_MINIMAL_LIBC */ #endif /* ZEPHYR_INCLUDE_TOOLCHAIN_LLVM_H_ */