Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFcccc
langcpp
// 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 DCL60-CPP. Obey the Oneone-Definition Ruledefinition rule for more information on violations of the one-definition rule.

...

Bibliography

[ISO/IEC 14882-2014]

Subclause 3.2, "One Definition Rule"
Subclause 7.1.2, "Function Specifiers"
Subclause 7.3.1, "Namespace Definition"

...