MISRA C:2012 Rule 8.6
An identifier with external linkage shall have exactly one external definition
Description
This checker is deactivated in a default Polyspace® as You Code analysis. See Checkers Deactivated in Polyspace as You Code Analysis (Polyspace Access).
Rule Definition
An identifier with external linkage shall have exactly one external definition1 .
Rationale
If you use an identifier for which multiple definitions exist in different files or no definition exists, the behavior is undefined.
Multiple definitions in different files are not permitted by this rule even if the definitions are the same.
Polyspace Implementation
The checker flags multiple definitions only if the definitions occur in different files.
The checker does not consider tentative definitions as definitions. For instance, the following code does not violate the rule:
int val; int val=1;
The checker does not show a violation if a function is not defined at all but declared with external linkage and called in the source code.
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 |
Version History
Introduced in R2014b
See Also
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.