[previous] 3218 [next] File scope static, '%s', is only accessed in one function.
Declarations and Definitions

An object has been defined at file scope with internal linkage but it is only referenced in one function.

If the object is only going to be used in one function it may be better to define it at block scope so as to decrease its visibility and improve maintainability. Objects are sometimes defined at file scope deliberately in order to assist in debugging.

For example:


/*PRQA S 2017,3408 ++*/

static int x1 = 0;                      /* Message 3218 */

extern void f1(void)
{
}

extern void f2(void)
{
    static int x2 = 0;                  /* Message 3223 */

    ++x1;
    ++x2;
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents