Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-96420

Remove unnamed namespaces from all headers

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 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)

            Assignee:
            Unassigned Unassigned
            Reporter:
            billy.donahue@mongodb.com Billy Donahue
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: