Main Content
MISRA C++:2023 Rule 6.5.1
A function or object with external linkage should be introduced in a header file
Since R2024b
Description
Rule Definition
A function or object with external linkage should be introduced in a header file.
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, declare it static
or
in an unnamed namespace.
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: Advisory |
Version History
Introduced in R2024b