Skip to content

Commit 8537b65

Browse files
committed
toolchain: Replace GCC_VERSION, CLANG_VERSION and BUILD_ASSERT macros
GCC_VERSION is defined in a few modules, and those headers are often included first, so replace the one used in zephyr with TOOLCHAIN_GCC_VERSION. Do the same with CLANG_VERSION, replacing it with TOOLCHAIN_CLANG_VERSION. BUILD_ASSERT is also defined in include/toolchain/common.h, which might get included before gcc.h. We want to use the gcc-specific one instead of the general one. Signed-off-by: Keith Packard <[email protected]>
1 parent a95c93a commit 8537b65

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

include/zephyr/toolchain.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,19 @@
6868
#endif
6969

7070
/**
71-
* @def GCC_VERSION
71+
* @def TOOLCHAIN_GCC_VERSION
7272
* @brief GCC version in xxyyzz for xx.yy.zz. Zero if not GCC compatible.
7373
*/
74-
#ifndef GCC_VERSION
75-
#define GCC_VERSION 0
74+
#ifndef TOOLCHAIN_GCC_VERSION
75+
#define TOOLCHAIN_GCC_VERSION 0
7676
#endif
7777

7878
/**
79-
* @def CLANG_VERSION
79+
* @def TOOLCHAIN_CLANG_VERSION
8080
* @brief Clang version in xxyyzz for xx.yy.zz. Zero if not Clang compatible.
8181
*/
82-
#ifndef CLANG_VERSION
83-
#define CLANG_VERSION 0
82+
#ifndef TOOLCHAIN_CLANG_VERSION
83+
#define TOOLCHAIN_CLANG_VERSION 0
8484
#endif
8585

8686
/**

include/zephyr/toolchain/gcc.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414
* Macros to abstract compiler capabilities for GCC toolchain.
1515
*/
1616

17-
#define GCC_VERSION \
17+
#define TOOLCHAIN_GCC_VERSION \
1818
((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__)
1919

2020
/* GCC supports #pragma diagnostics since 4.6.0 */
21-
#if !defined(TOOLCHAIN_HAS_PRAGMA_DIAG) && (GCC_VERSION >= 40600)
21+
#if !defined(TOOLCHAIN_HAS_PRAGMA_DIAG) && (TOOLCHAIN_GCC_VERSION >= 40600)
2222
#define TOOLCHAIN_HAS_PRAGMA_DIAG 1
2323
#endif
2424

25-
#if !defined(TOOLCHAIN_HAS_C_GENERIC) && (GCC_VERSION >= 40900)
25+
#if !defined(TOOLCHAIN_HAS_C_GENERIC) && (TOOLCHAIN_GCC_VERSION >= 40900)
2626
#define TOOLCHAIN_HAS_C_GENERIC 1
2727
#endif
2828

29-
#if !defined(TOOLCHAIN_HAS_C_AUTO_TYPE) && (GCC_VERSION >= 40900)
29+
#if !defined(TOOLCHAIN_HAS_C_AUTO_TYPE) && (TOOLCHAIN_GCC_VERSION >= 40900)
3030
#define TOOLCHAIN_HAS_C_AUTO_TYPE 1
3131
#endif
3232

@@ -64,6 +64,7 @@
6464
#endif
6565

6666

67+
#undef BUILD_ASSERT /* clear out common version */
6768
/* C++11 has static_assert built in */
6869
#if defined(__cplusplus) && (__cplusplus >= 201103L)
6970
#define BUILD_ASSERT(EXPR, MSG...) static_assert(EXPR, "" MSG)

include/zephyr/toolchain/llvm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
#define __fallthrough __attribute__((fallthrough))
1515
#endif
1616

17-
#define CLANG_VERSION \
17+
#define TOOLCHAIN_CLANG_VERSION \
1818
((__clang_major__ * 10000) + (__clang_minor__ * 100) + \
1919
__clang_patchlevel__)
2020

2121
#define TOOLCHAIN_HAS_PRAGMA_DIAG 1
2222

23-
#if CLANG_VERSION >= 30800
23+
#if TOOLCHAIN_CLANG_VERSION >= 30800
2424
#define TOOLCHAIN_HAS_C_GENERIC 1
2525
#define TOOLCHAIN_HAS_C_AUTO_TYPE 1
2626
#endif

0 commit comments

Comments
 (0)