C & C++

C & C++

Made by DeepSource

Using storage specifier static inside an anonymous namespace is redundant CXX-C2021

Anti-pattern
Minor
Autofix

Using the storage specifier static inside an anonymous namespace is redundant. The anonymous namespace already limits the visibility of definitions to a single translation unit.

To fix the issue, simply remove the static specifier from the definitions inside the anonymous namespace. This will make the code more concise.

Bad practice

namespace {
  static int count = 0; // Redundant use of static
}

### Recommended
``cpp
namespace {
  int count = 0;
}