Skip to content

Commit

Permalink
build system: Add MACRO_DEPRECATED macro
Browse files Browse the repository at this point in the history
Adding this macro in the definition of a macro causes a warning about
the deprecation to be emitted when used (and a build failure with
`WERROR=1`). This is useful as no other means to deprecate preprocessor
macros are provided.

The macro will be defined empty for compilers that are not GCC or
clang.
  • Loading branch information
maribu committed Apr 11, 2024
1 parent 58d495f commit 41ad849
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions dist/tools/genconfigheader/riotbuild-prefix.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,23 @@
*/
#define CPU_RAM_SIZE /* RAM Size in Bytes */
#endif /* DOXYGEN */

/**
* @brief Mark a preprocessor macro as deprecated by including this
* macro in the definition
*
* Usage:
* ``` C
* /// @deprecated, use @ref BAR instead of FOO
* #define FOO MACRO_DEPRECATED BAR
* ```
*/
#if defined(DOXYGEN)
# define MACRO_DEPRECATED /* implementation */
#elif defined(__GNUC__) || defined(__clang__)
# define MACRO_DEPRECATED _Pragma("GCC warning \"Code is using a deprecated macro\"")
#else
# define MACRO_DEPRECATED
#endif

/** @} */

0 comments on commit 41ad849

Please sign in to comment.