Skip to content

Commit 7eba25f

Browse files
pdgendtcfriedt
authored andcommitted
include: zephyr: toolchain: Introduce macros to ignore -Wcast-qual
Allow enabling/disabling the -Wcast-qual warning, for example to cast away constness. Signed-off-by: Pieter De Gendt <[email protected]>
1 parent 730efd9 commit 7eba25f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

include/zephyr/toolchain.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,17 @@
246246
#define TOOLCHAIN_WARNING_UNUSED_VARIABLE
247247
#endif
248248

249+
/**
250+
* @def TOOLCHAIN_WARNING_CAST_QUAL
251+
* @brief Toolchain-specific warning for pointer casts removing a type qualifier.
252+
*
253+
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
254+
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
255+
*/
256+
#ifndef TOOLCHAIN_WARNING_CAST_QUAL
257+
#define TOOLCHAIN_WARNING_CAST_QUAL
258+
#endif
259+
249260
/**
250261
* @def TOOLCHAIN_DISABLE_WARNING
251262
* @brief Disable the specified compiler warning for all compilers.

include/zephyr/toolchain/gcc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ do { \
684684
#define TOOLCHAIN_WARNING_SHADOW "-Wshadow"
685685
#define TOOLCHAIN_WARNING_UNUSED_LABEL "-Wunused-label"
686686
#define TOOLCHAIN_WARNING_UNUSED_VARIABLE "-Wunused-variable"
687+
#define TOOLCHAIN_WARNING_CAST_QUAL "-Wcast-qual"
687688

688689
/* GCC-specific warnings that aren't in clang. */
689690
#if defined(__GNUC__) && !defined(__clang__)

0 commit comments

Comments
 (0)