A macro is defined a second time with another body while the first definition is in force

tx0/c:macro-redefineddefaultwarningreliability/logicdepth fastbug

What it finds

#define TIMEOUT 30 and further down #define TIMEOUT 60: redefining a macro with a different body without an #undef between breaks a constraint of the standard; compilers warn and keep the last one, so code between the two reads one value and code after them the other.

The two definitions must be able to take effect together, not in different branches of a conditional directive, with no #undef of the name between them and no #include, since included files often remove the macros they use. A definition in a group whose condition tests the macro itself, as #ifndef NAME does, is a default and is left alone.

From the rule's source, macro_redefined.rs.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/c:macro-redefined" = "off"

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:macro-redefined] reason="..."

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