include: gcc.h: Add a __WARN() macro with a custom warning on expansion

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 https://github.com/zephyrproject-rtos/zephyr/pull/21506.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
This commit is contained in:
Ulf Magnusson 2020-01-30 09:11:25 +01:00 committed by Anas Nashif
commit 46f98d86c7

View file

@ -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 */