MISRA C++:2008 Rule 3-3-1
Objects or functions with external linkage shall be declared in a header file
Description
Rule Definition
Objects or functions with external linkage shall be declared in a header file.1
Rationale
If you declare a function or object in a header file, it is clear that the function or
        object is meant to be accessed in multiple translation units. If you intend to access the
        function or object from a single translation unit, reduce its visibility in other
        translation units by declaring the object as  static or in an unnamed
        namespace.
Polyspace Implementation
Polyspace® reports a violation of this rule if you declare an object or function with external linkage outside of a header file. These objects and functions have external linkage when they are declared at the namespace level, unless they are part of an explicitly unnamed namespace:
- Functions not declared - static
- Non- - constvariables not declared- static
- Variables declared - extern
- Enumerations 
- Names of classes, class member functions, static data members 
- Names of nested class and enumerations 
- Names of - friendfunctions declared within the class body
Functions and extern objects declared at a block scope
        also have external linkage.
For details about which objects and functions have external linkage, see Storage class specifiers.
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
| Group: Basic Concepts | 
| Category: Required | 
Version History
Introduced in R2013b
1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace Bug Finder™ documentation are from the following MISRA standards:
- MISRA C:2004 
- MISRA C:2012 
- MISRA C:2023 
- MISRA C++:2008 
- MISRA C++:2023 
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.