| 1 |
.. title:: clang-tidy - readability-static-definition-in-anonymous-namespace |
| 2 |
|
| 3 |
readability-static-definition-in-anonymous-namespace |
| 4 |
==================================================== |
| 5 |
|
| 6 |
Finds static function and variable definitions in anonymous namespace. |
| 7 |
|
| 8 |
In this case, ``static`` is redundant, because anonymous namespace limits the |
| 9 |
visibility of definitions to a single translation unit. |
| 10 |
|
| 11 |
.. code-block:: c++ |
| 12 |
|
| 13 |
namespace { |
| 14 |
static int a = 1; // Warning. |
| 15 |
static const int b = 1; // Warning. |
| 16 |
namespace inner { |
| 17 |
static int c = 1; // Warning. |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
The check will apply a fix by removing the redundant ``static`` qualifier. |