Why is this an issue?
Since C++11, declaring a variable, class, or function in an unnamed namespace
gives it internal linkage. Similarly, marking a
declaration static
also gives it internal linkage. Because both mechanisms have the same effect (although static
has a
narrower application) using them together is clearly redundant.
Noncompliant code example
namespace {
static int i = 3; // Noncompliant
}
Compliant solution
namespace {
int i = 3;
}
Resources
- ISO/IEC 14882:2011 §3.5 paragraph 4