MISRA C:2025 Rule 8.19
R2026bDescription
There should be no external declarations in a source file. 1
Rationale
An extern declaration in a source file creates a dependency that is
not expressed through the header include mechanism. If the type or signature of the declared
symbol changes in the defining translation unit, the compiler cannot detect the mismatch in
other translation units that redeclare the symbol locally. Declaring all external interfaces
in header files centralizes the interface and makes it easier to address changes to the
external functions and variables.
Polyspace Implementation
The coding rule checker reports a violation of this rule when a nonheader source file
contains an extern declaration of an object or function. The declaration
can appear at file scope or at block scope inside a function body.
No violation is reported when the extern declaration appears in a
header file.
Troubleshooting
If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
| Group: Declarations and definitions |
| Category: Advisory |
| AGC Category: Advisory |
PQL Name:
std.misra_c_2025.R8_19
|
Version History
Introduced in R2026b
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:2025
MISRA C++:2008
MISRA C++:2023
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.