== Why is this an issue? Placing the declarations of objects and functions with external linkage in a header file documents that they are intended to be accessible from other translation units. If external linkage is not required, then the object or function shall either be declared in an unnamed namespace or declared ``++static++``. This will reduce the visibility of objects and functions, which is considered to be good practice. === Noncompliant code example [source,cpp] ---- // header.hpp extern int32_t a1; extern void f3 ( ); // file1.cpp #include "header.hpp" int32_t a1 = 0; // Compliant, implicitly "extern" and declared in a header int32_t a2 = 0; // Non-compliant, implicitly "extern" but not declared in a header static int32_t a3 = 0; // Compliant, "static" namespace { int32_t a4 = 0; // Compliant, in an unnamed namespace void f1 () { } // Compliant, in an unnamed namespace } static void f2 ( ) { } // Compliant, "static" void f3 ( ) { } // Compliant, implicitly "extern" and declared in a header void f4 ( ) { } // Non-compliant, implicitly "extern" but not declared in a header void main ( ) { } // Compliant by exception ---- === Exceptions This rule does not apply to main, or to members of unnamed namespaces. == Resources * MISRA {cpp}:2008, 3-3-1 ifdef::env-github,rspecator-view[] ''' == Comments And Links (visible only on this page) === duplicates: S831 endif::env-github,rspecator-view[]