MISRA C++:2008 Rule 3-1-1
It shall be possible to include any header file in multiple translation units without violating the One Definition Rule
Description
Rule Definition
It shall be possible to include any header file in multiple translation units without violating the One Definition Rule.
Rationale
If a header file with variable or function definitions appears in multiple
inclusion paths, the header file violates the One Definition Rule possibly leading
to unpredictable behavior. For instance, a source file includes the header file
include.h
and another header file, which also includes
include.h
.
Polyspace Implementation
The rule checker flags variable and function definitions in header files.
Polyspace® reports violation of this rule in header files. In a nonheader source file, violation of this rule is not reported.
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: Required |
Version History
Introduced in R2013b