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 007f540 commit b2116bb
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions dist/tools/genconfigheader/riotbuild-prefix.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,26 @@
* not provided
*/
#define CPU_RAM_SIZE /* RAM Size in Bytes */

/**
* @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
* ```
*/
#define MACRO_DEPRECATED /* implementation */

#else /* DOXYGEN */

#if defined(__GNUC__) || defined(__clang__)
# define MACRO_DEPRECATED _Pragma("GCC warning \"Code is using a deprecated macro\"")
#else
# define MACRO_DEPRECATED
#endif

#endif /* DOXYGEN */
/** @} */

0 comments on commit b2116bb

Please sign in to comment.