Commit b10cedce authored by Victor Gao's avatar Victor Gao Committed by Facebook Github Bot

add FOLLY_MAYBE_UNUSED

Summary: This adds a macro `FOLLY_MAYBE_UNUSED` in `folly/CppAttributes.h` that can be used to suppress `-Wunused` warnings.

Reviewed By: yfeldblum

Differential Revision: D5444742

fbshipit-source-id: b16e8efefd76282498ad6114bac9548064cf38d5
parent 99b781df
...@@ -53,6 +53,26 @@ ...@@ -53,6 +53,26 @@
#define FOLLY_FALLTHROUGH #define FOLLY_FALLTHROUGH
#endif #endif
/**
* Maybe_unused indicates that a function, variable or parameter might or
* might not be used, e.g.
*
* int foo(FOLLY_MAYBE_UNUSED int x) {
* #ifdef USE_X
* return x;
* #else
* return 0;
* #endif
* }
*/
#if FOLLY_HAS_CPP_ATTRIBUTE(maybe_unused)
#define FOLLY_MAYBE_UNUSED [[maybe_unused]]
#elif FOLLY_HAS_CPP_ATTRIBUTE(gnu::unused)
#define FOLLY_MAYBE_UNUSED [[gnu::unused]]
#else
#define FOLLY_MAYBE_UNUSED
#endif
/** /**
* Nullable indicates that a return value or a parameter may be a `nullptr`, * Nullable indicates that a return value or a parameter may be a `nullptr`,
* e.g. * e.g.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment