...
| Code Block | ||||
|---|---|---|---|---|
| ||||
// a.h
#ifndef A_HEADER_FILE
#define A_HEADER_FILE
namespace {
int v;
}
inline int get_v() { return v; }
#endif // A_HEADER_FILE
// a.cpp
#include "a.h"
void f() {
int i = get_v();
// ...
}
// b.cpp
#include "a.h"
void g() {
int i = get_v();
// ...
} |
See MSC52DCL60-CPP. Obey the oneOne-definition ruleDefinition Rule for more information on violations of the one-definition rule.
...
Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Clang |
| google-build-namespaces | Checked by clang-tidy | ||||||
| LDRA tool suite |
| 286 S, 512 S | Fully implemented | ||||||
| Parasoft C/C++test | 9.5 | CODSTA-74 | |||||||
| SonarQube C/C++ Plugin |
| UnnamedNamespaceInHeader |
...
| SEI CERT C++ Coding Standard | MSC52DCL60-CPP. Obey the oneOne-definition ruleDefinition Rule |
Bibliography
| [ISO/IEC 14882-2014] | Subclause 3.2, "One Definition Rule" |
...