File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -223,6 +223,30 @@ extern "C" {
223223#define IF_ENABLED (_flag , _code ) \
224224 COND_CODE_1(_flag, _code, ())
225225
226+ /**
227+ * @brief Insert code if @p _flag is not defined as 1.
228+ *
229+ * This expands to nothing if @p _flag is defined and equal to 1;
230+ * it expands to @p _code otherwise.
231+ *
232+ * Example:
233+ *
234+ * IF_DISABLED(CONFIG_FLAG, (uint32_t foo;))
235+ *
236+ * If @p CONFIG_FLAG isn't defined or different than 1, this expands to:
237+ *
238+ * uint32_t foo;
239+ *
240+ * and to nothing otherwise.
241+ *
242+ * IF_DISABLED does the opposite of IF_ENABLED.
243+ *
244+ * @param _flag evaluated flag
245+ * @param _code result if @p _flag does not expand to 1; must be in parentheses
246+ */
247+ #define IF_DISABLED (_flag , _code ) \
248+ COND_CODE_1(_flag, (), _code)
249+
226250/**
227251 * @brief Check if a macro has a replacement expression
228252 *
You can’t perform that action at this time.
0 commit comments