A header's guard tests one macro and then defines another, so the guard never closes

tx0/c:include-guard-defines-other-namedefaultwarningreliability/logicdepth fastbug

What it finds

#ifndef PARSER_H followed by #define PARSRE_H: the guard tests a name it never defines, so a second inclusion reads the whole header again and its type definitions fail to compile, or, with a header of macros only, silently redefine them.

The header's first directive must be #ifndef with a name, the next one a #define of another name without parameters or body, and the group must end at the last conditional directive of the file. A file that defines the tested name anywhere else is left alone.

From the rule's source, include_guard_defines_other_name.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:include-guard-defines-other-name" = "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:include-guard-defines-other-name] reason="..."

tx0 explain tx0/c:include-guard-defines-other-name shows the same in the terminal. Found a false positive? Report it.