1.. title:: clang-tidy - misc-use-internal-linkage 2 3misc-use-internal-linkage 4========================= 5 6Detects variables and functions that can be marked as static or moved into 7an anonymous namespace to enforce internal linkage. 8 9Static functions and variables are scoped to a single file. Marking functions 10and variables as static helps to better remove dead code. In addition, it gives 11the compiler more information and allows for more aggressive optimizations. 12 13Example: 14 15.. code-block:: c++ 16 17 int v1; // can be marked as static 18 19 void fn1() {} // can be marked as static 20 21 namespace { 22 // already in anonymous namespace 23 int v2; 24 void fn2(); 25 } 26 // already declared as extern 27 extern int v2; 28 29 void fn3(); // without function body in all declaration, maybe external linkage 30 void fn3(); 31 32 // export declarations 33 export void fn4() {} 34 export namespace t { void fn5() {} } 35 export int v2; 36 37Options 38------- 39 40.. option:: FixMode 41 42 Selects what kind of a fix the check should provide. The default is `UseStatic`. 43 44 ``None`` 45 Don't fix automatically. 46 47 ``UseStatic`` 48 Add ``static`` for internal linkage variable and function. 49