-
Type: Bug
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
Server Programmability
-
ALL
-
SP Prioritized List
Never place unnamed namespaces (i.e. namespace {") in headers.
It would seem that a reminder about this would be useful.
There are 36 instances of them in the codebase.
Most are very recent, added in the last 2 years or so.
A few are special documented cases, but the vast majority are not.
This is banned by the style guide (all style guides, I think) and it's a dangerous practice.
Basically it's a bug factory for undiagnosable One Definition Rule violations.
Except in extremely unusual technical corner cases, it should not be necessary.
When you need a "hiding place" in a header, consider a named xxx_detail namespace, where xxx is a pretty unique snake case identifier for the component the header is declaring.
We should ticket these out to code owners for immediate attention.
They should be easy!
https://google.github.io/styleguide/cppguide.html#Internal_Linkage
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#sf21-dont-use-an-unnamed-anonymous-namespace-in-a-header (edited)