A macro defined in a source file is never used in it

tx0/c:unused-macrostrictwarningmaintainability/dead-codedepth fastsmell

What it finds

#define BUFFER_SIZE 512 in a source file, with BUFFER_SIZE mentioned nowhere else in it: a macro of a source file is visible to that file only, so one that is never used is dead and leaves a reader wondering what it was for.

Only source files count, not headers, and only macros defined after the last #include, since one defined before it may configure what the header declares. The name must occur nowhere else in the code of the file: not in code, other macros, conditional directives or branches that are not read.

A macro that only names a constant, as #define CTRL_RESET 0x04 or #define IRQ_MASK (BIT(3) | BIT(4)) do, is left alone: a list of them documents the registers or the format a file works with, used or not.

From the rule's source, unused_macro.rs.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/c:unused-macro" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/c:unused-macro] reason="..."

tx0 explain tx0/c:unused-macro shows the same in the terminal. Found a false positive? Report it.