Skip to content

Commit 975592b

Browse files
jonathonpenixabrarnasirjaffari
authored andcommitted
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: llvm/llvm-project#123514 Signed-off-by: Jonathon Penix <[email protected]>
1 parent 1ed253a commit 975592b

File tree

1 file changed

+8
-0
lines changed
  • include/zephyr/toolchain

1 file changed

+8
-0
lines changed

include/zephyr/toolchain/llvm.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
*/
4242
#ifdef CONFIG_MINIMAL_LIBC
4343

44+
/*
45+
* Predefined __INTN_C/__UINTN_C macros are provided by clang starting in version 20.
46+
* Avoid redefining these macros if a sufficiently modern clang is being used.
47+
*/
48+
#if __clang_major__ < 20
49+
4450
#define __int_c(v, suffix) v ## suffix
4551
#define int_c(v, suffix) __int_c(v, suffix)
4652
#define uint_c(v, suffix) __int_c(v ## U, suffix)
@@ -132,6 +138,8 @@
132138
#define __INTMAX_C(x) int_c(x, __INTMAX_C_SUFFIX__)
133139
#define __UINTMAX_C(x) int_c(x, __UINTMAX_C_SUFFIX__)
134140

141+
#endif /* __clang_major__ < 20 */
142+
135143
#endif /* CONFIG_MINIMAL_LIBC */
136144

137145
#endif /* ZEPHYR_INCLUDE_TOOLCHAIN_LLVM_H_ */

0 commit comments

Comments
 (0)