Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/lib: define MAYBE_UNUSED #18884

Merged
merged 2 commits into from
Nov 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions core/lib/include/compiler_hints.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ extern "C" {
* @brief The *NORETURN* keyword tells the compiler to assume that the function
* cannot return.
*/
#ifndef NORETURN
jue89 marked this conversation as resolved.
Show resolved Hide resolved
#ifdef __GNUC__
#define NORETURN __attribute__((noreturn))
#else
#define NORETURN
#endif
#endif

/**
* @def PURE
Expand All @@ -43,11 +45,26 @@ extern "C" {
* function can be subject to common subexpression elimination and loop
* optimization just as an arithmetic operator would be.
*/
#ifndef PURE
jue89 marked this conversation as resolved.
Show resolved Hide resolved
#ifdef __GNUC__
#define PURE __attribute__((pure))
#else
#define PURE
#endif
#endif

/**
* @def MAYBE_UNUSED
* @brief tell the compiler something may be unused
* static functions, function arguments, local variables
*/
#ifndef MAYBE_UNUSED
#ifdef __GNUC__
#define MAYBE_UNUSED __attribute__((unused))
#else
#define MAYBE_UNUSED
#endif
#endif

/**
* @def UNREACHABLE()
Expand Down