Skip to content

Commit

Permalink
include: gcc.h: Add a __WARN() macro with a custom warning on expansion
Browse files Browse the repository at this point in the history
Works like __DEPRECATED_MACRO with a custom message. Can do this for
example:

    #define FOO __WARN("Please use BAR instead") ...

Implement __DEPRECATED_MACRO with __WARN().

Useful for zephyrproject-rtos#21506.

Signed-off-by: Ulf Magnusson <[email protected]>
  • Loading branch information
ulfalizer authored and nashif committed Feb 1, 2020
1 parent 279e5b4 commit 46f98d8
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions include/toolchain/gcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,24 @@ do { \
#define HAS_BUILTIN___builtin_ctzll 1
#endif

/* Be *very* careful with this, you cannot filter out with -wno-deprecated,
* which has implications for -Werror
/*
* Be *very* careful with these. You cannot filter out __DEPRECATED_MACRO with
* -wno-deprecated, which has implications for -Werror.
*/

/*
* Expands to nothing and generates a warning. Used like
*
* #define FOO __WARN("Please use BAR instead") ...
*
* The warning points to the location where the macro is expanded.
*/
#define __WARN(msg) __WARN1(GCC warning msg)
#define __WARN1(s) _Pragma(#s)

/* Generic message */
#ifndef __DEPRECATED_MACRO
#define __DEPRECATED_MACRO _Pragma("GCC warning \"Macro is deprecated\"")
#define __DEPRECATED_MACRO __WARN("Macro is deprecated")
#endif

/* These macros allow having ARM asm functions callable from thumb */
Expand Down

0 comments on commit 46f98d8

Please sign in to comment.