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. 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, 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
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.