A header has an unnamed namespace, which gives every file that includes it a copy of its contents
What it finds
An unnamed namespace gives its contents internal linkage in each translation unit. In a header, every file that includes it gets its own copy of the functions and variables, which wastes space and makes mutable state silently per file.
From the rule's source, anonymous_namespace_in_header.rs.
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/cpp:anonymous-namespace-in-header" = "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/cpp:anonymous-namespace-in-header] reason="..."tx0 explain tx0/cpp:anonymous-namespace-in-header shows the same in the terminal. Found a false positive? Report it.