A header is included twice in the same file
What it finds
#include "list.h" written twice at the top level of a file: the second does nothing if the header has a guard, and declares everything again if it has none.
Both must stand outside conditional directives and have no #define or #undef between them, which would let a header be included again on purpose with other macros, as X-macro lists are. The fix removes the second line.
From the rule's source, duplicate_include.rs.
#include <stdio.h>#include "list.h"#include <stdio.h>tx0 reports: <stdio.h> is already included above#define ITEM(x) x,#include "items.h"#undef ITEM#define ITEM(x) #x,#include "items.h"#ifdef EXTRA#include "list.h"#endif Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/c:duplicate-include" = "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:duplicate-include] reason="..."tx0 explain tx0/c:duplicate-include shows the same in the terminal. Found a false positive? Report it.