MISRA C:2025 Rule 8.18
R2026bDescription
There shall be no tentative definitions in a header file.1
Rationale
A variable declaration at file scope without the extern keyword and
without an initializer is a tentative declaration. Tentative declaration can result in
multiple instances of an object, where each source file that includes the header creates a
an independent instance. This can be unexpected and can result in incorrect behavior
Polyspace Implementation
Polyspace® reports a violation of this rule when a header file contains:
A variable declaration at file scope without the
externkeyword and without an initializer. This kind of declaration is referred to as tentative declaration.A function definition (function with a body)
A
structdefinition that simultaneously declares an instance of that structAn array definition at file scope
The checker does not flag:
Declarations using the
externkeywordFunction prototypes without a body
structtype definitions without an accompanying instancetypedefdeclarations
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: Declarations and definitions |
| Category: Required |
| AGC Category: Required |
PQL Name: std.misra_c_2025.R8_18 |
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.