MISRA C:2025 Rule 8.4
R2026bA compatible declaration shall be visible when an object or function with external linkage is defined
Since R2026b
Description
A compatible declaration shall be visible when an object or function with external linkage is defined 1 .
Rationale
If a declaration is visible when an object or function is defined, it allows the compiler to check that the declaration and the definition are compatible.
This rule with MISRA C:2012 Rule 8.5 enforces the practice of declaring
an object (or function) in a header file and including the header file in source files that
define or use the object (or function).
Polyspace Implementation
The rule checker detects situations where:
An object or function is defined without a visible declaration.
There is a data type mismatch between the object or function declaration and definition. Such a mismatch also causes a compilation error.
The checker now flags tentative definitions (variables declared without an
extern specifier and not explicitly defined). To avoid the rule
violation, declare the variable static (defined in one file only), or
declare the variable extern and follow the declaration with a
definition.
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: Required |
| AGC Category: Required |
PQL Name:
std.misra_c_2025.R8_4
|
Version History
Introduced in R2026b
See Also
MISRA C:2025 Rule
8.2 | MISRA C:2025 Rule
8.3 | MISRA C:2025 Rule
8.5 | MISRA C:2025 Rule
17.3
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.